/* Global Variables & Theming - Luxury Dark Gold */
:root {
    --bg-color: #121212;            /* Deep black background */
    --card-bg: #1e1e1e;             /* Elegant dark grey cards */
    --primary-color: #d4af37;       /* Novus Habitat Gold */
    --primary-hover: #b89626;       /* Darker Gold */
    --text-main: #f8fafc;           /* Crisp white for text */
    --text-muted: #94a3b8;          /* Soft grey for secondary text */
    --border-color: #333333;        /* Subtle divider lines */
    --input-bg: #2d2d2d;            /* Background for form fields */
    --danger-color: #ef4444;        /* For removing issues */
    
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.5);
    --shadow-gold: 0 4px 15px rgba(212, 175, 55, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* App Container (Mobile First approach) */
.app-container {
    max-width: 850px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* Header & Brand Logo */
.app-header {
    text-align: center;
    margin-bottom: 32px;
}

.brand-logo {
    max-height: 85px;
    margin: 0 auto 16px auto;
    display: block;
    object-fit: contain;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--primary-color); 
}

.app-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Typography & General Layout */
.section-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.pb-1 {
    padding-bottom: 16px;
}

/* Issues Header wrapper */
.issues-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.issues-header .section-title {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.badge {
    background: var(--primary-color);
    color: #000; /* Contrast against gold */
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 700;
}

/* Form Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}

input[type="text"], 
input[type="date"],
input[type="email"],
input[type="password"], 
textarea,
select {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background-color: var(--input-bg);
    color: var(--text-main);
}

/* Customizing date picker icon color if possible */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

input[type="text"]:focus, 
input[type="date"]:focus,
input[type="email"]:focus,
input[type="password"]:focus, 
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15); /* Gold outline */
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* File Input Design */
.file-upload-wrapper {
    position: relative;
    border: 2px dashed rgb(80, 80, 80);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
    background-color: var(--bg-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-upload-wrapper:hover {
    border-color: var(--primary-color);
    background-color: #1a1a1a; 
}

.file-upload-wrapper input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-upload-wrapper span {
    font-weight: 500;
    color: var(--primary-color);
    pointer-events: none;
}

/* Image Previews Wrapper */
.image-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.image-preview-item {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

/* Issue Card Specifics */
.issue-card {
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.issue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.issue-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-color); /* Emphasize title with Gold */
}

.btn-remove {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-remove:hover {
    background-color: rgba(239, 68, 68, 0.1);
}


/* Buttons */
.btn-primary, .btn-secondary {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #121212; /* Black text on gold button for immense contrast */
    box-shadow: var(--shadow-gold);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}
.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    margin-bottom: 30px;
}

.btn-secondary:hover {
    background-color: rgba(212, 175, 55, 0.1);
}

/* Utils */
.hidden {
    display: none !important;
}

.error-text {
    color: var(--danger-color);
    font-size: 0.85rem;
    margin-top: -20px;
    margin-bottom: 20px;
}

/* Item Action Buttons */
.btn-check {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    transition: all 0.2s ease;
}

.btn-ok {
    border: 1px solid #22c55e;
    color: #22c55e;
}

.btn-ok:hover, .btn-active-ok {
    background-color: rgba(34, 197, 94, 0.1);
}
.btn-active-ok {
    background-color: #22c55e;
    color: #121212;
}

.btn-defect {
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.btn-defect:hover, .btn-active-defect {
    background-color: rgba(239, 68, 68, 0.1);
}
.btn-active-defect {
    background-color: var(--danger-color);
    color: #ffffff;
}

.defect-details {
    margin-top: 16px;
    padding-left: 16px;
    border-left: 2px solid var(--border-color);
    animation: fadeIn 0.3s ease-out;
}

/* Loading Spinner */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    color: var(--text-muted);
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255,255,255,0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Language Selector */
.lang-selector {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    gap: 12px;
    background: var(--card-bg);
    padding: 10px;
    border-radius: 30px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    z-index: 1000;
}

.lang-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.lang-btn:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

.lang-btn.active {
    opacity: 1;
    transform: scale(1.2);
    filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.5));
}

/* Utilities for Responsive Forms */
.flex-row-responsive {
    display: flex;
    gap: 10px;
}

@media (max-width: 650px) {
    .flex-row-responsive {
        flex-direction: column;
        gap: 0;
    }
}

/* ============================
   TOP NAVIGATION BAR
   ============================ */
#app-navbar {
    position: sticky;
    top: 0;
    z-index: 500;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.navbar-inner {
    max-width: 850px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-logo {
    max-height: 32px;
    object-fit: contain;
}

.navbar-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-color);
    white-space: nowrap;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.navbar-username {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 4px;
}

.btn-nav {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-nav:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-nav-logout:hover {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

/* ============================
   VIEW SYSTEM
   ============================ */
.view-container {
    min-height: calc(100vh - 55px);
}

/* ============================
   LOGIN VIEW
   ============================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at 50% 0%, rgba(212, 175, 55, 0.08) 0%, transparent 60%);
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 48px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    animation: fadeIn 0.4s ease-out;
}

.login-logo {
    max-height: 70px;
    margin: 0 auto 20px;
    display: block;
    object-fit: contain;
}

.login-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 6px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 28px;
}

/* ============================
   DASHBOARD VIEW
   ============================ */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 12px;
    padding-top: 24px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.btn-new-report {
    width: auto;
    padding: 10px 18px;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Report card in dashboard */
.report-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    animation: fadeIn 0.3s ease-out;
}

.report-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-gold);
}

.report-card-info {
    flex: 1;
    min-width: 0;
}

.report-card-location {
    font-weight: 600;
    font-size: 0.97rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-card-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.report-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.status-badge {
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-draft {
    background: rgba(212, 175, 55, 0.15);
    color: var(--primary-color);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.status-completed {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.btn-icon {
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-edit {
    background: rgba(212, 175, 55, 0.1);
    color: var(--primary-color);
    border-color: rgba(212, 175, 55, 0.3);
}

.btn-edit:hover {
    background: var(--primary-color);
    color: #121212;
}

.btn-delete {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger-color);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-delete:hover {
    background: var(--danger-color);
    color: #fff;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

/* ============================
   ADMIN PANEL
   ============================ */
.admin-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.admin-user-row:last-child {
    border-bottom: none;
}

.admin-user-info {
    flex: 1;
}

.admin-user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.admin-user-email {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.role-badge {
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.role-admin {
    background: rgba(212, 175, 55, 0.15);
    color: var(--primary-color);
}

.role-inspector {
    background: rgba(100, 100, 255, 0.12);
    color: #8b8fff;
}

/* Draft save toast notification */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #1e293b;
    border: 1px solid #334155;
    color: #f8fafc;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8);
    z-index: 2147483647;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    text-align: center;
}

.toast.toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-success {
    border-color: rgba(34, 197, 94, 0.5);
    color: #22c55e;
}

.toast-error {
    border-color: rgba(239, 68, 68, 0.5);
    color: var(--danger-color);
}

/* ============================
   MOBILE RESPONSIVE OVERRIDES
   ============================ */
@media (max-width: 650px) {
    .report-card, .admin-user-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .report-card-actions, .admin-user-row > div:last-child {
        width: 100%;
        margin-top: 12px;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .report-card-actions > select, .admin-user-row select {
        flex: 1 1 100%;
        margin-bottom: 8px;
    }

    .btn-icon {
        flex: 1;
        text-align: center;
        justify-content: center;
    }

    /* Navbar Mobile Fallbacks */
    .navbar-inner {
        flex-direction: column;
        gap: 14px;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .navbar-actions {
        width: 100%;
        justify-content: center;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .navbar-username {
        display: none !important; 
    }

    .btn-nav {
        flex: 1;
        justify-content: center;
    }
}
