:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --bg: #f8fafc;
    --text: #1e293b;
    --text-light: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --card: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

* { 
    box-sizing: border-box; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
}

body { 
    margin: 0; 
    background-color: var(--bg); 
    color: var(--text);
    padding-bottom: 80px;
    padding-top: env(safe-area-inset-top);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }
.p-20 { padding: 20px; }
.text-center { text-align: center; }

/* Top Bar */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

header #back-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

header h1 { 
    font-size: 1.1rem; 
    margin: 0; 
    font-weight: 600;
}

/* Bottom Nav */
#bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 70px;
    background: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
    z-index: 100;
}

#bottom-nav .nav-btn {
    background: none; 
    border: none;
    display: flex; 
    flex-direction: column;
    align-items: center; 
    font-size: 0.7rem; 
    color: var(--text-light);
    cursor: pointer;
    padding: 8px 12px;
    transition: color 0.2s;
}

#bottom-nav .nav-btn.active {
    color: var(--primary);
}

#bottom-nav ion-icon { 
    font-size: 1.5rem; 
    margin-bottom: 4px; 
}

/* Page Container */
.page-container {
    min-height: calc(100vh - 140px);
    padding-bottom: 20px;
}

/* Auth Pages */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container .logo {
    font-size: 2.5rem;
    font-weight: bold;
    color: white;
    margin-bottom: 40px;
    text-align: center;
}

.auth-container input {
    width: 100%;
    max-width: 400px;
    padding: 14px 16px;
    margin: 10px 0;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    background: white;
    box-shadow: var(--shadow);
}

.auth-container .btn-primary {
    width: 100%;
    max-width: 400px;
    margin-top: 20px;
}

.auth-container .btn-link {
    background: none;
    border: none;
    color: white;
    margin-top: 15px;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
}

/* Buttons */
.btn-primary {
    width: 100%; 
    background: var(--primary); 
    color: white;
    border: none; 
    padding: 14px 20px; 
    border-radius: 10px;
    font-weight: 600; 
    font-size: 1rem; 
    margin-top: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

.btn-small {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

/* Inputs */
input, textarea, select {
    width: 100%; 
    padding: 12px 16px; 
    margin: 8px 0;
    border: 1px solid var(--border); 
    border-radius: 10px;
    font-size: 1rem;
    background: white;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

/* Cards */
.card {
    background: white; 
    padding: 20px;
    border-radius: 12px; 
    box-shadow: var(--shadow);
    margin-bottom: 15px;
}

.notice-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.notice-card h3 {
    margin-top: 0;
    font-size: 1.1rem;
}

.notice-card p {
    margin-bottom: 0;
    opacity: 0.95;
}

/* Lists */
.list-item {
    background: white; 
    padding: 16px;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    border-radius: 12px; 
    margin-bottom: 12px; 
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.list-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.list-item strong {
    display: block;
    margin-bottom: 4px;
    font-size: 1rem;
}

.list-item p {
    margin: 0;
    color: var(--text-light);
    font-size: 0.85rem;
}

.list-item ion-icon {
    color: var(--text-light);
    font-size: 1.2rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.stat-item {
    background: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-item strong {
    display: block;
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 5px;
}

.stat-item span {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Inspection Form */
.inspection-form {
    padding: 20px;
}

.inspection-step {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.inspection-step label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 1rem;
    color: var(--text);
}

.status-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-status {
    flex: 1;
    padding: 12px 20px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: white;
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-status.active {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-status.fail.active {
    background: var(--danger);
    border-color: var(--danger);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.checkbox-group label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
}

.btn-nfc {
    width: 100%; 
    padding: 20px; 
    border: 2px dashed var(--primary);
    background: #eff6ff; 
    color: var(--primary); 
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
}

.btn-nfc:hover {
    background: var(--primary);
    color: white;
}

.btn-nfc.scanned {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.photo-upload {
    margin-top: 10px;
}

.photo-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.photo-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview-item .remove-photo {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: block;
    padding: 12px;
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
}

.file-input-label:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: white;
    padding: 5px;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.tabs button {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
}

.tabs button.active {
    background: var(--primary);
    color: white;
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
}

.chat-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.chat-message.sent {
    align-items: flex-end;
}

.chat-message.received {
    align-items: flex-start;
}

.chat-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.chat-message.sent .chat-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.received .chat-bubble {
    background: white;
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

.chat-time {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 4px;
    padding: 0 4px;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: white;
    border-top: 1px solid var(--border);
}

.chat-input-area input {
    flex: 1;
    margin: 0;
}

.chat-input-area button {
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

/* Maintenance Request Form */
.maintenance-form {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.form-group .required {
    color: var(--danger);
}

.priority-badges {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.priority-badge {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.priority-badge.low {
    border-color: var(--success);
    color: var(--success);
}

.priority-badge.medium {
    border-color: var(--warning);
    color: var(--warning);
}

.priority-badge.high {
    border-color: var(--danger);
    color: var(--danger);
}

.priority-badge.active {
    background: currentColor;
    color: white;
}

/* Maintenance Issue View */
.issue-header {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.issue-status {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 10px;
}

.issue-status.pending {
    background: #fef3c7;
    color: #92400e;
}

.issue-status.in-progress {
    background: #dbeafe;
    color: #1e40af;
}

.issue-status.completed {
    background: #d1fae5;
    color: #065f46;
}

.comments-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-top: 15px;
    box-shadow: var(--shadow);
}

.comment-item {
    padding: 15px;
    border-left: 3px solid var(--primary);
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 10px;
}

.comment-author {
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text);
}

.comment-time {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.comment-text {
    color: var(--text);
    line-height: 1.5;
}

/* Settings */
.settings-list {
    padding: 20px;
}

.settings-item {
    background: white;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.settings-item-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-item-icon {
    font-size: 1.5rem;
    color: var(--primary);
}

.settings-item-text {
    display: flex;
    flex-direction: column;
}

.settings-item-text strong {
    font-size: 1rem;
    margin-bottom: 2px;
}

.settings-item-text span {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Info/Support */
.info-section {
    padding: 20px;
}

.info-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.info-card h3 {
    margin-top: 0;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-card p {
    color: var(--text);
    line-height: 1.6;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.contact-item:last-child {
    border-bottom: none;
}

.contact-item ion-icon {
    font-size: 1.5rem;
    color: var(--primary);
}

/* History */
.history-filter {
    padding: 20px;
    background: white;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.history-item {
    background: white;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--success);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
}

.history-item-date {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state ion-icon {
    font-size: 4rem;
    color: var(--border);
    margin-bottom: 20px;
}

.empty-state h3 {
    margin-bottom: 10px;
    color: var(--text);
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg);
    color: var(--text);
}

.badge.urgent {
    background: var(--danger);
    color: white;
}

.badge.due-today {
    background: var(--warning);
    color: white;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}
