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

:root {
    /* Ant Design v4 - Dark Theme (Default) */
    --primary-color: #177ddc;
    --primary-hover: #1765ad;
    --primary-active: #165996;

    --bg-body: #000000;
    --bg-card: #141414;
    --bg-header: #141414;
    --bg-input: #141414;
    --bg-hover: #1f1f1f;

    --text-color: rgba(255, 255, 255, 0.85);
    --text-color-secondary: rgba(255, 255, 255, 0.45);
    --text-color-heading: rgba(255, 255, 255, 0.85);

    --border-color-base: #434343;
    --border-color-split: #303030;

    --shadow-card: 0 1px 2px -2px rgba(0, 0, 0, 0.64), 0 3px 6px 0 rgba(0, 0, 0, 0.48), 0 5px 12px 4px rgba(0, 0, 0, 0.36);
    --shadow-header: 0 2px 8px rgba(0, 0, 0, 0.45);

    --success-color: #52c41a;
    --error-color: #ff4d4f;
    --warning-color: #faad14;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --border-radius-base: 2px;
    --border-radius-lg: 4px;
    /* Ant Design usually simpler radius */

    /* Spacing */
    --padding-lg: 24px;
    --padding-md: 16px;
    --padding-sm: 12px;
}

[data-theme="light"] {
    /* Ant Design v4 - Light Theme */
    --primary-color: #1890ff;
    /* Ant Design Blue */
    --primary-hover: #40a9ff;
    --primary-active: #096dd9;

    --bg-body: #f0f2f5;
    /* Light grey background */
    --bg-card: #ffffff;
    --bg-header: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f5f5f5;

    --text-color: rgba(0, 0, 0, 0.85);
    --text-color-secondary: rgba(0, 0, 0, 0.45);
    --text-color-heading: rgba(0, 0, 0, 0.85);

    --border-color-base: #d9d9d9;
    --border-color-split: #f0f0f0;

    --shadow-card: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);
    --shadow-header: 0 2px 8px #f0f1f2;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-color);
    line-height: 1.5715;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--padding-lg);
}

/* Header */
.header {
    background: var(--bg-header);
    box-shadow: var(--shadow-header);
    margin-bottom: 24px;
    height: 64px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.header-content {
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    max-width: 1400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.logo svg path {
    fill: var(--text-color-heading);
    transition: fill 0.3s ease;
}

[data-theme="dark"] .logo svg path[fill="white"] {
    fill: #141414;
    /* Invert the inner part for dark mode if needed, or keeping it distinct */
}

/* Fix SVG logo colors for themes */
.logo-icon-path {
    fill: var(--primary-color);
}

.logo-bg-path {
    fill: var(--bg-card);
}


.logo h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color-heading);
    margin: 0;
}

.nav-links {
    display: flex;
    gap: 0;
    margin-left: 40px;
}

.nav-link {
    color: var(--text-color-heading);
    text-decoration: none;
    padding: 0 20px;
    height: 64px;
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
    position: relative;
    border-bottom: 2px solid transparent;
}

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

.nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: transparent;
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}

.user-profile a {
    color: var(--text-color-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.user-profile a:hover {
    color: var(--text-color);
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-color-base);
    color: var(--text-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

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

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color-split);
    border-radius: var(--border-radius-base);
    padding: var(--padding-lg);
    box-shadow: none;
    /* Ant Design usually flat with border or slight shadow */
}

.section-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text-color-heading);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Inputs & Forms */
.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    font-size: 14px;
    color: var(--text-color);
    margin-bottom: 8px;
}

select,
textarea,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"] {
    width: 100%;
    padding: 4px 11px;
    background: var(--bg-input);
    border: 1px solid var(--border-color-base);
    border-radius: var(--border-radius-base);
    color: var(--text-color);
    font-size: 14px;
    height: 32px;
    /* Standard Ant Height */
    transition: all 0.3s;
}

textarea {
    height: auto;
    padding: 4px 11px;
}

select:hover,
textarea:hover,
input:hover {
    border-color: var(--primary-color);
}

select:focus,
textarea:focus,
input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 4px 15px;
    font-size: 14px;
    border-radius: var(--border-radius-base);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
    border: 1px solid var(--border-color-base);
    background: var(--bg-card);
    color: var(--text-color);
    user-select: none;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.015);
}

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

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
}

.btn-secondary {
    /* Same as default btn but explicit */
}

/* Inventory Specifics */
.toolbar-container {
    background: var(--bg-card);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color-split);
    border-radius: var(--border-radius-base);
}

.data-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
    border-radius: var(--border-radius-base);
}

.data-grid thead th {
    background: #fafafa;
    color: var(--text-color);
    font-weight: 500;
    text-align: left;
    padding: 16px;
    border-bottom: 1px solid var(--border-color-split);
    transition: background 0.3s;
}

[data-theme="dark"] .data-grid thead th {
    background: #1d1d1d;
}

.data-grid tbody td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color-split);
    color: var(--text-color);
    transition: background 0.3s;
}

.data-grid tbody tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .data-grid tbody tr:hover td {
    background: rgba(255, 255, 255, 0.04);
}

.thumbnail {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid var(--border-color-split);
}

/* Filter Tags (if used) */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 24px;
}

/* Status Badges */
.status-badge {
    padding: 0 7px;
    font-size: 12px;
    line-height: 20px;
    border-radius: 2px;
    border: 1px solid;
    display: inline-block;
}

.status-available,
.status-active {
    background: #f6ffed;
    border-color: #b7eb8f;
    color: #52c41a;
}

.status-sold {
    background: #fff1f0;
    border-color: #ffa39e;
    color: #ff4d4f;
}

[data-theme="dark"] .status-available {
    background: #162312;
    border-color: #274916;
    color: #49aa19;
}

[data-theme="dark"] .status-sold {
    background: #2a1215;
    border-color: #58181c;
    color: #a61d24;
}

/* Left Pane: Inventory List */
.sidebar-pane {
    background: var(--bg-card);
    border-right: 1px solid var(--border-color-split);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    z-index: 10;
    width: 400px;
    /* Fixed width as requested */
    flex-shrink: 0;
}

.unit-list-item {
    /* Resetting legacy styles to be safe, though used as base class */
    display: block;
    /* Changed from flex to block for internal layout control if needed, but flex row is good for image + content */
    display: flex;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color-split);
    /* Separator style */
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.unit-list-item:hover {
    background: var(--bg-hover);
}

.unit-list-item.selected {
    background: #e6f7ff;
    /* Light blue tint */
    border-left: 4px solid var(--primary-color);
}

[data-theme="dark"] .unit-list-item.selected {
    background: rgba(23, 125, 220, 0.15);
}

/* High Density Card Styles */
.lc-top {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.lc-thumb {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
    background: #eee;
    flex-shrink: 0;
}

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

.lc-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.lc-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.lc-id-badge {
    font-size: 10px;
    background: var(--bg-hover);
    color: var(--text-color-secondary);
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 6px;
}

.lc-price {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-color-heading);
}

.lc-status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    /* Pill shape */
    font-size: 11px;
    font-weight: 500;
    text-transform: capitalize;
}

.lc-status-pending {
    background: rgba(250, 173, 20, 0.2);
    color: #faad14;
}

.lc-status-active {
    background: rgba(82, 196, 26, 0.2);
    color: #52c41a;
}

.lc-status-sold {
    background: rgba(255, 77, 79, 0.2);
    color: #ff4d4f;
}

.lc-footer {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color-split);
    color: var(--text-color-secondary);
    font-size: 12px;
}

.lc-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--border-radius-base);
    box-shadow: var(--shadow-card);
    width: 100%;
    max-width: 600px;
}

/* Campaign Manager - Unit Grid */
.unit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    /* Responsive columns */
    gap: 24px;
    padding-top: 16px;
}

.unit-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color-split);
    border-radius: var(--border-radius-base);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
    position: relative;
    padding: 16px;
}

.unit-card:hover {
    box-shadow: var(--shadow-card);
    border-color: var(--border-color-base);
}

.unit-card.selected {
    border-color: var(--primary-color);
    background: var(--bg-hover);
}

.unit-image-container {
    width: 100%;
    height: 180px;
    margin-bottom: 12px;
    border-radius: var(--border-radius-base);
    overflow: hidden;
    background: var(--bg-body);
}

.unit-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.unit-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-color-secondary);
}

.unit-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-color-heading);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unit-details {
    font-size: 14px;
    color: var(--text-color);
    flex-grow: 1;
}

.btn-text {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 12px;
    text-decoration: underline;
}

.btn-text.success {
    color: var(--success-color);
}

/* Mobile specific elements */
.mobile-back-btn {
    display: none;
}

@media (max-width: 768px) {

    /* Header Optimization */
    .header {
        height: 56px;
        /* Compact header */
        margin-bottom: 0;
        padding: 0;
    }

    .header-content {
        padding: 0 12px;
        flex-wrap: nowrap;
        /* Prevent wrapping */
    }

    .logo h1 {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 140px;
    }

    .nav-links {
        display: none;
        /* Hide nav links */
    }

    .user-controls {
        gap: 8px;
    }

    .user-profile {
        display: none;
        /* Hide user profile text */
    }

    /* Stack the main layout */
    .dashboard-container {
        display: block;
        /* Remove grid */
        position: relative;
        height: calc(100vh - 110px);
        /* Adjust for header */
        overflow: hidden;
    }

    /* Sidebar full width by default */
    .sidebar-pane {
        width: 100%;
        border-right: none;
        display: flex;
    }

    /* Unit List Items: Larger Touch Targets */
    .unit-list-item {
        padding: 16px;
        /* Larger hit area */
        gap: 16px;
    }

    .lc-thumb {
        width: 80px;
        /* Slightly larger thumbnail */
        height: 80px;
    }

    .lc-title {
        font-size: 15px;
        /* Larger title text */
    }

    /* Main pane hidden by default on mobile */
    .main-pane {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        background: var(--bg-body);
        z-index: 20;
        display: none;
        /* Hidden until item selected */
    }

    /* When mobile detail is active */
    body.mobile-detail-active .sidebar-pane {
        display: none;
    }

    body.mobile-detail-active .main-pane {
        display: block;
    }

    /* Modals */
    .modal,
    .glass-panel {
        width: 90% !important;
        max-width: none !important;
        max-height: 85vh !important;
        padding: 16px !important;
    }

    /* Edit Grid */
    .edit-grid {
        grid-template-columns: 1fr;
    }

    /* Vitals Ribbon: Scrollable & Spaced */
    .vitals-ribbon {
        margin: 0 -16px 20px -16px;
        padding: 12px 16px;
        gap: 24px;
        /* More space between items */
    }

    .vr-item {
        font-size: 14px;
        /* Larger text */
    }

    .vr-icon {
        font-size: 18px;
    }

    /* Detail Header */
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 12px 0 20px 0;
    }

    .dh-left,
    .dh-center,
    .dh-actions {
        width: 100%;
        align-items: flex-start;
    }

    .dh-price {
        font-size: 28px;
        /* Prominent Price */
    }

    .dh-actions {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .dh-actions .btn {
        flex: 1;
        /* Stretch buttons */
        height: 40px;
        /* Taller buttons */
    }

    .cc-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Split Grid in Detail */
    .split-grid {
        grid-template-columns: 1fr;
    }

    /* Filter Grid */
    .filter-grid {
        grid-template-columns: 1fr;
    }

    #sidebarFilters {
        max-height: 60vh;
    }

    /* Mobile Back Button */
    .mobile-back-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 12px;
        color: var(--primary-color);
        font-weight: 600;
        font-size: 15px;
        cursor: pointer;
        padding: 8px 0;
        /* Easier to tap */
        background: none;
        border: none;
    }

    .unit-image-container {
        height: 220px;
        /* Taller images on mobile */
    }
}


/* --- Command Center: List View Items --- */
.lc-thumb {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 4px;
    /* match design crispness */
    overflow: hidden;
    background: #000;
}

.lc-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.lc-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.lc-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

/* --- Command Center: Detail View Layout --- */
.detail-header {
    position: relative;
    /* was sticky */
    /* top: 0; removed */
    z-index: 20;
    background: var(--bg-body);
    /* Blend with body */
    border-bottom: 1px solid var(--border-color-split);
    padding: 16px 0;
    margin-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dh-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dh-left h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.dh-center {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dh-price {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-color-heading);
    letter-spacing: -0.5px;
}

.dh-actions {
    display: flex;
    gap: 12px;
}

/* Vitals Ribbon */
.vitals-ribbon {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color-split);
    padding: 12px 24px;
    margin: 0 -24px 24px -24px;
    /* Negative margin to span full width of main-pane padding */
    display: flex;
    gap: 32px;
    align-items: center;
    overflow-x: auto;
}

.vr-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-color);
    white-space: nowrap;
}

.vr-icon {
    font-size: 16px;
    opacity: 0.6;
}

.vr-val {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color-heading);
}

.vr-label {
    color: var(--text-color-secondary);
}

/* Grid Layout */
.detail-body {
    padding-bottom: 60px;
}

.split-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    /* approx 62% / 38% */
    gap: 24px;
    align-items: start;
}

/* Cards */
.cc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color-split);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cc-card-header {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color-base);
    padding-bottom: 12px;
    color: var(--text-color-heading);
}

/* Images */
.img-carousel-container {
    background: #000;
    border-radius: 8px;
    height: 360px;
    /* Fixed height is good */
    width: 100%;
    /* Constrain to parent container width */
    max-width: 100%;
    /* safety */
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.img-carousel-main {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Scale up to fit borders while keeping aspect ratio */
    display: block;
}

/* Grid Columns */
.col-visuals {
    min-width: 0;
    /* Critical for wrapping/scrolling inside grid */
}

/* Thumbs */
.img-thumbs {
    display: flex;
    gap: 10px;
    padding-bottom: 4px;
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    /* Ensure it doesn't push grid width */
    scrollbar-width: thin;
    /* Firefox */
}

.img-thumbs::-webkit-scrollbar {
    height: 6px;
}

.img-thumbs::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.img-thumb {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.7;
    transition: all 0.2s;
    flex-shrink: 0;
    /* Prevent shrinking, force scroll */
}

.img-thumb:hover {
    opacity: 1;
    border-color: var(--primary-color);
}

/* Owner Card Specifics */
.owner-card .status-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(82, 196, 26, 0.1);
    color: #52c41a;
    border: 1px solid rgba(82, 196, 26, 0.2);
}

@media (max-width: 1100px) {
    .split-grid {
        grid-template-columns: 1fr;
    }
}