/**
 * InmoWeb CRM - Core Design System & Responsive Framework
 * Mobile-First, Modern Real Estate Aesthetics with Light/Dark Themes & Micro-Animations
 */

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

:root {
    /* Brand Primary Palette (Deep Indigo / Electric Cyan / Emerald) */
    --primary: #0f172a;          /* Slate 900 */
    --primary-light: #1e293b;    /* Slate 800 */
    --primary-dark: #020617;     /* Slate 950 */
    --accent: #0284c7;           /* Sky 600 */
    --accent-hover: #0369a1;     /* Sky 700 */
    --accent-light: #e0f2fe;     /* Sky 100 */
    --accent-gold: #c9a961;      /* Luxury Gold */
    --accent-emerald: #10b981;   /* Emerald 500 */

    /* Neutrals */
    --bg-main: #f8fafc;          /* Slate 50 */
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --border-color: #e2e8f0;     /* Slate 200 */
    --border-focus: #0284c7;
    --text-main: #0f172a;        /* Slate 900 */
    --text-muted: #64748b;       /* Slate 500 */
    --text-light: #94a3b8;       /* Slate 400 */

    /* Functional Colors */
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --info: #0ea5e9;
    --info-bg: #f0f9ff;
    --purple: #8b5cf6;
    --purple-bg: #f5f3ff;

    /* Spacing & Layout */
    --sidebar-width: 260px;
    --header-height: 68px;
    --mobile-nav-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Mode Overrides */
body.dark-theme {
    --bg-main: #0b0f19;
    --bg-surface: #111827;
    --bg-card: #1f2937;
    --bg-input: #111827;
    --border-color: #374151;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --text-light: #6b7280;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    font-size: 0.925rem;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
body.dark-theme ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

/* App Container Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ── HEADER (Top Bar) ── */
.app-header {
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

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

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.brand-badge {
    background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
    color: white;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-name {
    font-weight: 800;
    background: linear-gradient(135deg, #0284c7, #1e293b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
body.dark-theme .brand-name {
    background: linear-gradient(135deg, #38bdf8, #f8fafc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 700;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 7-Day Trial Status Pill */
.trial-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fef3c7;
    color: #92400e;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid #fde68a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: var(--transition-fast);
}
.trial-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}
.trial-badge i {
    color: #d97706;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.trial-badge.badge-master {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #f59e0b;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
}
.trial-badge.badge-master i {
    color: #d97706;
}
.trial-badge.badge-subscribed {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}
.trial-badge.badge-subscribed i {
    color: #16a34a;
}
.trial-badge.badge-expired {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.quick-action-btn {
    background: var(--accent);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}
.quick-action-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}
.icon-btn:hover {
    background: var(--bg-main);
    border-color: var(--accent);
    color: var(--accent);
}

.badge-counter {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-surface);
}

/* User Profile Widget */
.user-widget {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}
.user-widget:hover {
    background: var(--bg-main);
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--accent);
}
.user-details {
    display: flex;
    flex-direction: column;
    text-align: left;
}
.user-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 1.2;
}
.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ── SIDEBAR NAVIGATION ── */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: #e2e8f0;
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 90;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform var(--transition-slow);
}

.sidebar-menu {
    list-style: none;
    padding: 16px 12px;
}

.sidebar-category {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #64748b;
    font-weight: 700;
    padding: 16px 12px 6px;
}

.sidebar-item {
    margin-bottom: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}
.sidebar-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}
.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}
.sidebar-link.active {
    background: linear-gradient(90deg, rgba(2, 132, 199, 0.25) 0%, rgba(2, 132, 199, 0.05) 100%);
    color: #38bdf8;
    font-weight: 700;
    border-left: 3px solid #38bdf8;
}

.sidebar-footer {
    padding: 16px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.feedback-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f8fafc;
    padding: 10px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-fast);
}
.feedback-btn:hover {
    background: rgba(2, 132, 199, 0.2);
    border-color: #0284c7;
    color: #38bdf8;
}

/* ── MAIN CONTENT WRAPPER ── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    flex: 1;
    min-height: calc(100vh - var(--header-height));
    padding: 28px;
    background: var(--bg-main);
    width: calc(100% - var(--sidebar-width));
    transition: margin-left var(--transition-slow);
}

.section-view {
    display: none;
    animation: fadeIn 0.3s ease;
}
.section-view.active {
    display: block;
}

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

/* Page Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
}
.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── UI COMPONENTS: BUTTONS, CARDS, INPUTS ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
    text-decoration: none;
}
.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}
.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-main);
    border-color: var(--text-muted);
}
.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover {
    background: #059669;
}
.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    background: #dc2626;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    transition: var(--transition-normal);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}
.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Forms & Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}
.form-grid.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}
.form-grid.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}
.form-group.full {
    grid-column: 1 / -1;
}
.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-main);
    font-size: 0.9rem;
    transition: var(--transition-fast);
    outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}
.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ── MODALS ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}
.modal-overlay.active {
    display: flex;
}
.modal-container {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-container.modal-lg {
    max-width: 1000px;
}
.modal-container.modal-sm {
    max-width: 500px;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}
.modal-close {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
}
.modal-close:hover {
    color: var(--danger);
}
.modal-body {
    padding: 24px;
}
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-main);
    border-bottom-left-radius: var(--radius-xl);
    border-bottom-right-radius: var(--radius-xl);
}

/* ── MOBILE DRAWER & BOTTOM NAV ── */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 8px;
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
    justify-content: space-around;
    align-items: center;
}
.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    gap: 4px;
    flex: 1;
    height: 100%;
    cursor: pointer;
}
.mobile-nav-item i {
    font-size: 1.2rem;
}
.mobile-nav-item.active {
    color: var(--accent);
}

/* Toast Notifications */
#inmoweb-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--primary);
    color: white;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 400px;
    animation: toastIn 0.3s ease;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.toast-success { border-left: 4px solid var(--success); }
.toast-danger { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--info); }

/* ── RESPONSIVE BREAKPOINTS ── */
@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.active {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
        width: 100%;
        padding: 20px 16px 80px;
    }
    .mobile-menu-btn {
        display: block;
    }
    .mobile-bottom-nav {
        display: flex;
    }
    .form-grid.grid-4,
    .form-grid.grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .app-header {
        padding: 0 14px;
    }
    .header-center {
        display: none;
    }
    .form-grid,
    .form-grid.grid-4,
    .form-grid.grid-3 {
        grid-template-columns: 1fr;
    }
    .user-details {
        display: none;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .page-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .page-actions .btn {
        flex: 1;
        justify-content: center;
    }
    .modal-container {
        width: 95% !important;
        max-width: 95% !important;
        margin: 12px auto;
        padding: 16px !important;
        max-height: 92vh;
    }
    .modal-body {
        max-height: calc(92vh - 110px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}
