/* ============================================================
   Maximus Paint Calculator — Main Stylesheet
   Version: 6.0 | PHP/MySQL/HTML5/CSS3/JS
   ============================================================ */

/* ========== Reset & Base ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.5;
    min-height: 100vh;
}
a { color: #1a56db; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ========== CSS Variables ========== */
:root {
    --primary: #1a56db;
    --primary-dark: #1543b0;
    --primary-light: #e8f0fe;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-muted: #687076;
    --border: #e5e7eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --nav-height: 64px;
    --bottom-nav-height: 60px;
}

/* ========== Login Screen ========== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 20px;
}
.login-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-card .logo { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-card .form-group { text-align: left; margin-bottom: 16px; }
.login-card label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: #555; }
.login-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.15); }
.login-card .btn-login {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s, transform 0.1s;
}
.login-card .btn-login:hover { background: var(--primary-dark); }
.login-card .btn-login:active { transform: scale(0.98); }
.login-error { color: var(--error); font-size: 13px; margin-top: 12px; display: none; }

/* ========== App Layout ========== */
.app-container { display: none; min-height: 100vh; padding-bottom: var(--bottom-nav-height); }

/* Top Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.app-header .header-left { display: flex; align-items: center; gap: 12px; }
.app-header .header-left h1 { font-size: 18px; font-weight: 700; }
.app-header .header-right { display: flex; align-items: center; gap: 12px; }
.app-header .user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--primary-light);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
}
.app-header .user-badge .role-tag {
    font-size: 10px;
    text-transform: uppercase;
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 6px;
}
.btn-logout {
    padding: 6px 14px;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--error); color: var(--error); }

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    height: var(--bottom-nav-height);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    transition: color 0.2s;
    border: none;
    background: none;
    position: relative;
    padding: 4px 0;
}
.nav-item:hover { color: var(--primary); }
.nav-item.active { color: var(--primary); font-weight: 700; }
.nav-item .nav-icon { font-size: 22px; line-height: 1; }
.nav-item .badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    background: var(--error);
    color: white;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ========== Page Content ========== */
.page { display: none; padding: 16px; max-width: 800px; margin: 0 auto; }
.page.active { display: block; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 16px; }

/* ========== Cards ========== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #1ea34e; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: #444; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ========== Wizard Steps ========== */
.wizard-progress {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
}
.wizard-step-indicator {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    transition: background 0.3s;
}
.wizard-step-indicator.active { background: var(--primary); }
.wizard-step-indicator.completed { background: var(--success); }
.wizard-step { display: none; }
.wizard-step.active { display: block; }
.wizard-nav { display: flex; justify-content: space-between; margin-top: 24px; gap: 12px; }

/* ========== Area Counter ========== */
.area-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}
.area-row:last-child { border-bottom: none; }
.area-info { flex: 1; }
.area-info .area-name { font-weight: 600; font-size: 14px; }
.area-info .area-detail { font-size: 12px; color: var(--text-muted); }
.area-controls { display: flex; align-items: center; gap: 8px; }
.area-controls .counter-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.area-controls .counter-btn:hover { border-color: var(--primary); color: var(--primary); }
.area-controls .counter-value { font-size: 18px; font-weight: 700; min-width: 28px; text-align: center; }
.coat-select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.ceiling-toggle { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); }
.ceiling-toggle input { width: auto; margin: 0; }

/* ========== Results / Breakdown ========== */
.result-total {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, #1a56db, #0f3460);
    color: white;
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.result-total .total-label { font-size: 14px; opacity: 0.8; }
.result-total .total-value { font-size: 36px; font-weight: 800; }
.breakdown-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.breakdown-table th { text-align: left; padding: 8px 12px; background: #f8f9fa; font-weight: 600; border-bottom: 2px solid var(--border); }
.breakdown-table td { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; }
.breakdown-table tr:last-child td { border-bottom: none; }
.breakdown-table .text-right { text-align: right; }
.breakdown-section { margin-bottom: 16px; }
.breakdown-section h4 { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--primary); }

/* ========== Stats Grid ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
    text-align: center;
}
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ========== Table ========== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 12px; background: #f8f9fa; font-weight: 600; border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }
.data-table tr:hover td { background: #fafbfc; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ========== Status Badges ========== */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.status-scheduled { background: #dbeafe; color: #1e40af; }
.status-in_progress { background: #fef3c7; color: #92400e; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-cancelled { background: #fee2e2; color: #991b1b; }

/* ========== Notification Items ========== */
.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}
.notif-item:hover { background: #f8f9fa; }
.notif-item.unread { border-left: 3px solid var(--primary); background: var(--primary-light); }
.notif-icon { font-size: 24px; flex-shrink: 0; }
.notif-content { flex: 1; }
.notif-content .notif-title { font-weight: 600; font-size: 14px; }
.notif-content .notif-body { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.notif-content .notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ========== Modal ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--surface);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover { background: #e0e0e0; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ========== Search / Filter Bar ========== */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-bar input,
.filter-bar select {
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    flex: 1;
    min-width: 140px;
}
.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ========== Job Cards ========== */
.job-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.job-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.job-card .job-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.job-card .job-title { font-weight: 700; font-size: 15px; }
.job-card .job-price { font-weight: 800; font-size: 18px; color: var(--primary); }
.job-card .job-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.job-card .job-meta span { display: flex; align-items: center; gap: 4px; }

/* ========== Schedule Cards ========== */
.schedule-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.schedule-info { flex: 1; }
.schedule-info .schedule-title { font-weight: 700; font-size: 15px; }
.schedule-info .schedule-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.schedule-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ========== Settings Tabs ========== */
.settings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}
.settings-tab {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.2s;
}
.settings-tab:hover { color: var(--primary); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* ========== PriceBook Table ========== */
.pricebook-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pricebook-table th { padding: 8px; background: #f8f9fa; text-align: center; font-weight: 600; border: 1px solid var(--border); }
.pricebook-table td { padding: 4px; border: 1px solid var(--border); text-align: center; }
.pricebook-table input {
    width: 70px;
    padding: 6px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}
.pricebook-table input:focus { border-color: var(--primary); outline: none; }

/* ========== Drywall Repairs ========== */
.drywall-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
}
.drywall-item .drywall-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.drywall-item .drywall-header strong { font-size: 14px; }
.drywall-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 480px) { .drywall-grid { grid-template-columns: 1fr; } }

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ========== Loading ========== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Toast ========== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 16px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
    max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.info { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========== Responsive ========== */
@media (max-width: 480px) {
    .app-header .user-badge .role-tag { display: none; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .result-total .total-value { font-size: 28px; }
    .page { padding: 12px; }
}

/* ========== Utilities ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }
