/* ============================================
   Prime Realtors Admin Panel
   ============================================ */

:root {
    --primary: #1a3a5c;
    --primary-light: #2a5a8c;
    --primary-dark: #0e2240;
    --accent: #c8a45e;
    --accent-light: #d4b978;
    --accent-dark: #a8864a;
    --text: #2d3748;
    --text-light: #718096;
    --text-lighter: #a0aec0;
    --bg: #f7f8fa;
    --bg-white: #ffffff;
    --bg-dark: #1a202c;
    --border: #e2e8f0;
    --success: #38a169;
    --warning: #d69e2e;
    --danger: #e53e3e;
    --info: #3182ce;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
    --sidebar-width: 240px;
}

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

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

a { text-decoration: none; color: inherit; }

/* ============ Login ============ */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    padding: 24px;
}

.login-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo-prime {
    display: block;
    font-family: Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 4px;
}

.logo-sub {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 5px;
    text-transform: uppercase;
    margin-top: 2px;
}

.login-card input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 12px;
    transition: var(--transition);
}

.login-card input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,58,92,0.1);
}

.login-error {
    color: var(--danger);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 12px;
    min-height: 20px;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

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

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    background: rgba(26,58,92,0.04);
}

.btn-ghost {
    background: transparent;
    color: var(--text-light);
    border: none;
    padding: 10px 16px;
}

.btn-ghost:hover {
    color: var(--text);
    background: rgba(0,0,0,0.04);
}

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

.btn-danger:hover {
    background: #c53030;
    border-color: #c53030;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 14px;
}

.btn-icon {
    padding: 8px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius);
    color: var(--text-light);
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(0,0,0,0.06);
    color: var(--text);
}

.btn-icon.danger:hover {
    color: var(--danger);
    background: rgba(229,62,62,0.08);
}

.btn-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ============ Layout ============ */
.admin {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-logo {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .logo-prime {
    color: #fff;
    font-size: 1.5rem;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255,255,255,0.6);
    transition: var(--transition);
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.sidebar-link.active {
    color: #fff;
    background: rgba(200,164,94,0.2);
}

.sidebar-link.active svg {
    color: var(--accent-light);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Main */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-left h1 {
    font-family: inherit;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    padding: 4px;
}

.admin-user {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    background: var(--bg);
    padding: 6px 14px;
    border-radius: 20px;
}

/* Tabs */
.tab-content {
    display: none;
    padding: 24px 32px;
}

.tab-content.active {
    display: block;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar h2 {
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 700;
}

.toolbar-left {
    display: flex;
    gap: 12px;
    flex: 1;
}

.search-input {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    width: 280px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,58,92,0.08);
}

.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--bg-white);
    cursor: pointer;
}

/* Stats */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}

.stat-card-number {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card-label {
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Table */
.table-wrapper {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.properties-table {
    width: 100%;
    border-collapse: collapse;
}

.properties-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.properties-table td {
    padding: 12px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.properties-table tr:last-child td {
    border-bottom: none;
}

.properties-table tr:hover td {
    background: rgba(26,58,92,0.02);
}

.table-thumb {
    width: 64px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg);
}

.table-thumb-placeholder {
    width: 64px;
    height: 44px;
    border-radius: 6px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-lighter);
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge.active { background: #c6f6d5; color: #22543d; }
.status-badge.pending { background: #fefcbf; color: #744210; }
.status-badge.sold { background: #fed7d7; color: #822727; }
.status-badge.draft { background: #e2e8f0; color: #4a5568; }

.prop-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(200,164,94,0.15);
    color: var(--accent-dark);
}

.table-actions {
    display: flex;
    gap: 4px;
}

.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-lighter);
}

.empty-state svg {
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ============ Form ============ */
.form-header {
    margin-bottom: 24px;
}

.form-header h2 {
    font-family: inherit;
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 16px;
}

.form-section {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 28px;
    margin-bottom: 20px;
}

.form-section h3 {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    transition: var(--transition);
    background: var(--bg-white);
}

.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,58,92,0.08);
}

.form-group textarea {
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-row-4 {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.url-input-row {
    display: flex;
    gap: 8px;
}

.url-input-row input {
    flex: 1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 0;
}

/* Image Upload */
.image-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-lighter);
}

.image-dropzone:hover {
    border-color: var(--accent);
    background: rgba(200,164,94,0.04);
}

.image-dropzone svg {
    margin-bottom: 12px;
}

.image-dropzone p {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 4px;
}

.image-dropzone span {
    font-size: 0.8rem;
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.image-preview-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4/3;
    background: var(--bg);
}

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

.image-preview-item .remove-image {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    transition: var(--transition);
}

.image-preview-item .remove-image:hover {
    background: var(--danger);
}

.image-preview-item .primary-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.image-preview-item .set-primary {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
}

.image-preview-item:hover .set-primary {
    opacity: 1;
}

.image-preview-item .set-primary:hover {
    background: var(--accent);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.modal p {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Danger Zone */
.danger-zone {
    border-color: #fed7d7;
}

.danger-zone h3 {
    color: var(--danger);
}

.danger-zone p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--primary);
    color: #fff;
    padding: 14px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ============ Responsive ============ */
@media (max-width: 1024px) {
    .form-row-4 {
        grid-template-columns: 1fr 1fr;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .main {
        margin-left: 0;
    }

    .topbar, .tab-content {
        padding-left: 16px;
        padding-right: 16px;
    }

    .form-row, .form-row-3, .form-row-4 {
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left {
        flex-direction: column;
    }

    .search-input {
        width: 100%;
    }

    .properties-table {
        font-size: 0.8rem;
    }

    .properties-table th:nth-child(n+4),
    .properties-table td:nth-child(n+4) {
        display: none;
    }

    .properties-table th:nth-child(8),
    .properties-table td:nth-child(8),
    .properties-table th:nth-child(9),
    .properties-table td:nth-child(9) {
        display: table-cell;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}
