@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

:root {
    --color-bg: #0a1628;
    --color-bg-2: #0f1d33;
    --color-bg-3: #132541;
    --color-surface: #162a48;
    --color-surface-2: #1b3358;
    --color-border: rgba(201, 169, 97, 0.18);
    --color-border-strong: rgba(201, 169, 97, 0.4);

    --color-text: #f5f1e8;
    --color-text-muted: #b8c4d4;
    --color-text-dim: #8a97ab;

    --color-gold: #c9a961;
    --color-gold-hover: #d7ba73;
    --color-gold-dim: #8c7540;

    --color-ok: #5aa36c;
    --color-warn: #d7a14a;
    --color-danger: #cf5a5a;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font: inherit; color: inherit; background: none; border: none; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--color-gold); text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }

/* ============================
   LOGIN
   ============================ */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
    background:
        radial-gradient(1000px 600px at 20% 10%, rgba(201, 169, 97, 0.08), transparent 60%),
        radial-gradient(800px 500px at 80% 90%, rgba(201, 169, 97, 0.05), transparent 60%),
        var(--color-bg);
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-bg-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
}
.login-brand {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    margin-bottom: 1.75rem;
}
.login-brand h1 { font-size: 1.4rem; }
.login-brand p { color: var(--color-text-dim); font-size: 0.85rem; }
.brand-mark {
    width: 48px; height: 48px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dim));
    color: var(--color-bg);
    font-family: var(--font-display);
    font-weight: 700;
    border-radius: 12px;
    letter-spacing: -0.02em;
}
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.4rem; }
.login-form label > span { font-size: 0.8rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.login-form input {
    background: var(--color-bg-3);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    color: var(--color-text);
    transition: border-color 200ms, background 200ms;
}
.login-form input:focus { outline: none; border-color: var(--color-gold); background: var(--color-surface); }
.login-error {
    color: var(--color-danger);
    background: rgba(207, 90, 90, 0.1);
    border: 1px solid rgba(207, 90, 90, 0.3);
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

.login-back {
    display: block;
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.82rem;
    color: var(--color-text-dim);
    text-decoration: none;
    transition: color 200ms;
}
.login-back:hover { color: var(--color-gold); }

.btn-primary {
    margin-top: 0.3rem;
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-hover));
    color: var(--color-bg);
    font-weight: 600;
    padding: 0.85rem 1.2rem;
    border-radius: 10px;
    transition: transform 200ms, box-shadow 200ms;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(201, 169, 97, 0.25); }
.btn-primary:disabled { opacity: 0.5; cursor: wait; transform: none; }

/* ============================
   DASHBOARD
   ============================ */
.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: var(--color-bg-2);
    border-right: 1px solid var(--color-border);
    padding: 1.5rem 1.1rem;
    display: flex;
    flex-direction: column;
}
.sidebar-brand {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.3rem 0.4rem 1.3rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.2rem;
}
.sidebar-brand strong { display: block; font-family: var(--font-display); font-size: 1.1rem; }
.sidebar-brand small { color: var(--color-text-dim); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    color: var(--color-text-muted);
    font-weight: 500;
    transition: background 200ms, color 200ms;
    text-align: left;
}
.nav-item:hover { background: var(--color-bg-3); color: var(--color-text); }
.nav-item.is-active {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: inset 3px 0 0 var(--color-gold);
}
.nav-badge {
    background: var(--color-bg-3);
    border: 1px solid var(--color-border);
    color: var(--color-text-dim);
    font-size: 0.72rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    min-width: 26px;
    text-align: center;
}
.nav-item.is-active .nav-badge { border-color: var(--color-gold-dim); color: var(--color-gold); }

.sidebar-user {
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.user-info strong { display: block; font-size: 0.9rem; }
.user-info small { color: var(--color-text-dim); font-size: 0.78rem; }
.btn-logout {
    font-size: 0.82rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    background: var(--color-bg-3);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    transition: background 200ms, color 200ms;
    text-align: center;
}
.btn-logout:hover { background: var(--color-surface); color: var(--color-text); }

/* ============================
   CONTENT AREA
   ============================ */
.content {
    padding: 2rem 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-x: hidden;
}
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--color-border);
}
.content-header h2 { font-size: 1.75rem; }
.content-actions { display: flex; gap: 0.6rem; align-items: center; }
.content-body { display: flex; flex-direction: column; gap: 1rem; }

/* ============================
   TABLES
   ============================ */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--color-bg-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.data-table thead th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-dim);
    padding: 0.9rem 1rem;
    background: var(--color-bg-3);
    border-bottom: 1px solid var(--color-border);
}
.data-table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(201, 169, 97, 0.03); }
.data-table .cell-muted { color: var(--color-text-dim); }
.data-table .cell-strong { font-weight: 600; }

.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--color-text-dim);
    background: var(--color-bg-2);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
}

/* ============================
   BADGES / CHIPS
   ============================ */
.status-chip {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid transparent;
}
.status-new, .status-pending         { background: rgba(215, 161, 74, 0.12); color: var(--color-warn); border-color: rgba(215, 161, 74, 0.35); }
.status-under_review                 { background: rgba(201, 169, 97, 0.12); color: var(--color-gold); border-color: var(--color-border-strong); }
.status-contacted, .status-approved, .status-published, .status-converted
                                     { background: rgba(90, 163, 108, 0.12); color: var(--color-ok); border-color: rgba(90, 163, 108, 0.35); }
.status-rejected, .status-lost       { background: rgba(207, 90, 90, 0.12); color: var(--color-danger); border-color: rgba(207, 90, 90, 0.35); }
.status-qualified, .status-archived, .status-inactive, .status-reserved
                                     { background: var(--color-bg-3); color: var(--color-text-muted); border-color: var(--color-border); }
.status-available, .status-sold, .status-rented
                                     { background: rgba(201, 169, 97, 0.1); color: var(--color-gold); border-color: var(--color-border); }

/* ============================
   BUTTONS (table actions + secondary)
   ============================ */
.btn-sm {
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    background: var(--color-bg-3);
    color: var(--color-text-muted);
    transition: background 200ms, color 200ms, border-color 200ms;
}
.btn-sm:hover { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-sm.is-primary { background: var(--color-gold); color: var(--color-bg); border-color: var(--color-gold); font-weight: 600; }
.btn-sm.is-primary:hover { background: var(--color-gold-hover); }
.btn-sm.is-danger { color: var(--color-danger); border-color: rgba(207, 90, 90, 0.3); }
.btn-sm.is-danger:hover { background: rgba(207, 90, 90, 0.1); color: var(--color-danger); }

.btn-add {
    background: var(--color-gold);
    color: var(--color-bg);
    font-weight: 600;
    padding: 0.55rem 1rem;
    border-radius: 10px;
    transition: background 200ms, transform 200ms;
}
.btn-add:hover { background: var(--color-gold-hover); transform: translateY(-1px); }

.actions-cell { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.filter-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.4rem;
}
.filter-bar select, .filter-bar input {
    background: var(--color-bg-2);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    color: var(--color-text);
    font-size: 0.85rem;
}
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--color-gold); }

/* ============================
   MODAL
   ============================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 12, 24, 0.72);
    display: grid;
    place-items: center;
    padding: 2rem;
    z-index: 100;
}
.modal {
    background: var(--color-bg-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.modal-header h3 { font-size: 1.3rem; }
.modal-close {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 8px;
    color: var(--color-text-dim);
    font-size: 1.2rem;
}
.modal-close:hover { background: var(--color-bg-3); color: var(--color-text); }
.modal-body { padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem 1rem;
}
.form-field { display: flex; flex-direction: column; gap: 0.35rem; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 0.75rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.form-field input, .form-field select, .form-field textarea {
    background: var(--color-bg-3);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
    color: var(--color-text);
    transition: border-color 200ms, background 200ms;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none; border-color: var(--color-gold); background: var(--color-surface);
}
.form-field textarea { resize: vertical; min-height: 80px; }

/* ============================
   PROPERTY MODAL — sections
   ============================ */
.property-modal-body { display: flex; flex-direction: column; gap: 1.5rem; }

.modal-section {
    padding: 1rem 1.1rem;
    background: var(--color-bg-3);
    border: 1px solid var(--color-border);
    border-radius: 12px;
}
.modal-section h4 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin-bottom: 0.9rem;
    color: var(--color-gold);
    letter-spacing: 0.01em;
}
.modal-section h5 {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.7rem;
}

.images-section { display: flex; flex-direction: column; gap: 1.5rem; }
.images-hint { color: var(--color-text-dim); font-size: 0.88rem; padding: 0.6rem 0; }

.cover-area, .gallery-area { display: flex; flex-direction: column; gap: 0.7rem; }

.cover-preview {
    width: 100%;
    height: 180px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--color-bg-2);
    border: 1px dashed var(--color-border);
    display: grid;
    place-items: center;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-placeholder { color: var(--color-text-dim); font-size: 0.85rem; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.6rem;
    min-height: 40px;
}
.gallery-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-bg-2);
    border: 1px solid var(--color-border);
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-delete {
    position: absolute;
    top: 4px; right: 4px;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(10, 22, 40, 0.85);
    color: #fff;
    font-size: 1.1rem;
    line-height: 1;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0;
    transition: opacity 180ms;
}
.gallery-thumb:hover .thumb-delete { opacity: 1; }
.thumb-delete:hover { background: var(--color-danger); }

.file-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1rem;
    background: var(--color-surface);
    border: 1px dashed var(--color-border-strong);
    border-radius: 10px;
    color: var(--color-gold);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 180ms, color 180ms;
    align-self: flex-start;
}
.file-btn:hover { background: var(--color-surface-2); color: var(--color-gold-hover); }

.detail-list { display: flex; flex-direction: column; gap: 0.75rem; }
.detail-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 1rem;
    font-size: 0.9rem;
}
.detail-row dt { color: var(--color-text-dim); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.08em; padding-top: 0.15rem; }
.detail-row dd { color: var(--color-text); }

.toast {
    position: fixed;
    top: 1.5rem; right: 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    padding: 0.8rem 1.1rem;
    border-radius: 10px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 200;
    animation: slide-in 250ms ease;
}
.toast.is-error { border-color: rgba(207, 90, 90, 0.5); color: var(--color-danger); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ============================
   RESPONSIVE — Tablet (≤900px)
   ============================ */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; min-height: auto; }

    .sidebar {
        flex-direction: column;
        gap: 0.85rem;
        padding: 0.9rem 1rem;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--color-bg-2);
    }
    .sidebar-brand {
        border-bottom: none;
        padding: 0;
        margin: 0;
    }
    .sidebar-brand strong { font-size: 1rem; }
    .sidebar-brand small { font-size: 0.7rem; }
    .sidebar-brand .brand-mark { width: 38px; height: 38px; font-size: 0.9rem; border-radius: 9px; }

    .sidebar-nav {
        flex-direction: row;
        gap: 4px;
        overflow-x: auto;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .sidebar-nav::-webkit-scrollbar { display: none; }
    .nav-item {
        flex: 0 0 auto;
        gap: 0.5rem;
        padding: 0.6rem 0.85rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    .nav-item.is-active { box-shadow: inset 0 -2px 0 var(--color-gold); }
    .nav-badge { font-size: 0.65rem; padding: 0.05rem 0.4rem; min-width: 22px; }

    .sidebar-user {
        border-top: 1px solid var(--color-border);
        padding-top: 0.75rem;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.6rem;
        flex-wrap: wrap;
    }
    .user-info { min-width: 0; flex: 1 1 auto; }
    .user-info strong { font-size: 0.82rem; }
    .user-info small { font-size: 0.72rem; }
    .btn-logout {
        flex: 0 0 auto;
        padding: 0.45rem 0.7rem;
        font-size: 0.75rem;
    }

    .content { padding: 1.25rem; }
    .form-grid { grid-template-columns: 1fr; }
    .detail-row { grid-template-columns: 1fr; gap: 0.2rem; }
}

/* ============================
   RESPONSIVE — Phone (≤760px)
   ============================ */
@media (max-width: 760px) {
    body { font-size: 13.5px; }

    /* Header stack */
    .content { padding: 1rem; gap: 1rem; }
    .content-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.7rem;
        padding-bottom: 0.85rem;
    }
    .content-header h2 { font-size: 1.4rem; }
    .content-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .filter-bar { width: 100%; }
    .filter-bar select, .filter-bar input { flex: 1 1 auto; min-width: 0; }
    .btn-add { width: 100%; padding: 0.7rem 1rem; }

    /* TABLES → cards */
    .data-table {
        border: 0;
        background: transparent;
        border-radius: 0;
        overflow: visible;
    }
    .data-table thead { display: none; }
    .data-table tbody, .data-table tr { display: block; width: 100%; }
    .data-table tr {
        background: var(--color-bg-2);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        padding: 0.85rem 1rem;
        margin-bottom: 0.7rem;
    }
    .data-table tbody tr:hover { background: var(--color-bg-2); }
    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.85rem;
        padding: 0.45rem 0;
        border-bottom: 1px dashed rgba(201, 169, 97, 0.1);
        text-align: right;
        word-break: break-word;
    }
    .data-table tbody td:last-child {
        border-bottom: none;
        padding-top: 0.65rem;
    }
    .data-table tbody td::before {
        content: attr(data-label);
        flex: 0 0 100px;
        text-align: left;
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--color-text-dim);
        padding-top: 0.1rem;
    }
    .data-table tbody td[data-label=""]::before,
    .data-table tbody td:not([data-label])::before { display: none; }
    .data-table .actions-cell {
        justify-content: flex-start;
        text-align: left;
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    .data-table .actions-cell::before { display: none; }
    .data-table .actions-cell .btn-sm {
        flex: 1 1 auto;
        min-width: 0;
        text-align: center;
        padding: 0.55rem 0.6rem;
    }

    /* MODAL — slide up from bottom (sheet-style) */
    .modal-backdrop {
        padding: 0;
        align-items: flex-end;
    }
    .modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        border-bottom: 0;
    }
    .modal-header { padding: 1rem 1.1rem; }
    .modal-header h3 { font-size: 1.05rem; }
    .modal-body { padding: 1rem 1.1rem; }
    .modal-footer {
        padding: 0.85rem 1.1rem;
        flex-direction: column-reverse;
        gap: 0.45rem;
    }
    .modal-footer .btn-sm {
        width: 100%;
        padding: 0.7rem;
        font-size: 0.88rem;
    }

    .modal-section { padding: 0.85rem 0.95rem; }
    .modal-section h4 { font-size: 1rem; margin-bottom: 0.7rem; }
    .form-grid { gap: 0.8rem; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 0.4rem; }
    .cover-preview { height: 150px; }

    .detail-row dt { font-size: 0.7rem; }
    .detail-row dd { font-size: 0.88rem; }

    /* TOAST anchored to bottom on mobile */
    .toast {
        top: auto;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        text-align: center;
    }
}

/* ============================
   RESPONSIVE — Small phone (≤420px)
   ============================ */
@media (max-width: 420px) {
    .content { padding: 0.85rem; }
    .login-shell { padding: 1rem; }
    .login-card { padding: 1.4rem; }
    .login-brand h1 { font-size: 1.2rem; }

    .data-table tr { padding: 0.75rem 0.85rem; }
    .data-table tbody td::before { flex-basis: 84px; font-size: 0.65rem; }

    .nav-item { padding: 0.55rem 0.7rem; font-size: 0.8rem; }
    .nav-badge { display: none; }
}
