/* ============================================
   AGENT LAYOUT CSS
   Layout, Sidebar, Navigation, Topbar,
   Main Content Area, and Responsive overrides
   Split from agent.css
   ============================================ */

/* ============================================
   AGENT LAYOUT & DASHBOARD CSS
   ============================================ */

/* Agent Layout */
.agent-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg-light);
}

.agent-sidebar {
    width: 260px;
    background: #FFFFFF;
    border-right: 1px solid #E5E7EB;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 250ms ease;
}

/* Collapsed state */
.agent-sidebar.collapsed {
    width: 72px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #F3F4F6;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #1A1A2E;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-logo .logo-full {
    height: 32px;
    display: block;
}

.sidebar-logo .logo-icon {
    height: 32px;
    display: none;
}

.agent-sidebar.collapsed .logo-full { display: none; }
.agent-sidebar.collapsed .logo-icon { display: block; }

/* Sidebar toggle button */
.agent-sidebar .sidebar-toggle {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #6B7280;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 150ms ease;
    flex-shrink: 0;
}

.agent-sidebar .sidebar-toggle:hover {
    background: #F8F9FA;
    color: #1A1A2E;
}

.agent-sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Nav text hide when collapsed */
.agent-sidebar .nav-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
}

.agent-sidebar.collapsed .nav-text {
    display: none;
}

.agent-sidebar.collapsed .sidebar-nav .nav-item {
    justify-content: center;
    padding: 12px;
}

.agent-sidebar.collapsed .sidebar-nav .badge {
    display: none;
}

.agent-sidebar.collapsed .nav-divider {
    margin: 0.5rem 0.75rem;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #6B7280;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 150ms ease;
    border-radius: 8px;
    margin-bottom: 4px;
}

.sidebar-nav .nav-item:hover {
    color: #1A1A2E;
    background: #F8F9FA;
}

.sidebar-nav .nav-item.active {
    color: white;
    background: #D4A03C;
}

.sidebar-nav .nav-item.active svg {
    stroke: white;
}

.sidebar-nav .badge {
    margin-left: auto;
    background: #dc2626;
    color: white;
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
}

.nav-divider {
    height: 1px;
    background: #F3F4F6;
    margin: 0.75rem 0;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid #F3F4F6;
}

/* Main Content Area */
.agent-main {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
    transition: margin-left 250ms ease;
}

.agent-sidebar.collapsed ~ .agent-main {
    margin-left: 72px;
}

.agent-topbar {
    height: 70px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.mobile-menu-btn {
    display: none;
    padding: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-gray);
}

.topbar-search {
    flex: 1;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-light);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.topbar-search svg {
    color: var(--text-gray);
}

.topbar-search input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 0.9375rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-btn {
    position: relative;
    padding: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-gray);
    transition: color 0.2s;
}

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

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 18px;
    height: 18px;
    background: #dc2626;
    color: white;
    font-size: 0.625rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-weight: 500;
    color: var(--text-dark);
}

.agent-content {
    flex: 1;
    padding: 1.5rem;
    overflow-x: hidden;
    min-width: 0;
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .actions-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Sidebar overlay (always defined, shown via Blazor conditional render) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 99;
    animation: fade-in 0.25s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 768px) {
    /* Sidebar: hide off-screen, slide in when .open */
    .agent-sidebar {
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .agent-sidebar.collapsed {
        width: 260px;
    }

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

    .agent-main {
        margin-left: 0;
    }

    .agent-sidebar.collapsed ~ .agent-main {
        margin-left: 0;
    }

    .agent-sidebar .sidebar-toggle {
        display: none;
    }

    .agent-sidebar.collapsed .nav-text {
        display: block;
    }

    .agent-sidebar.collapsed .sidebar-nav .nav-item {
        justify-content: flex-start;
        padding: 12px 16px;
    }

    .agent-sidebar.collapsed .sidebar-nav .badge {
        display: inline;
    }

    .agent-sidebar.collapsed .logo-full { display: block; }
    .agent-sidebar.collapsed .logo-icon { display: none; }

    .mobile-menu-btn {
        display: block;
    }

    .topbar-search {
        display: none;
    }

    .user-name {
        display: none;
    }

    /* Topbar: tighter padding */
    .agent-topbar {
        padding: 0 1rem;
        height: 56px;
        gap: 0.75rem;
    }

    /* Content: reduce padding */
    .agent-content {
        padding: 1rem;
    }

    /* Welcome section */
    .welcome-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .welcome-content h1 {
        font-size: 1.375rem;
    }

    /* Stats grids */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    /* Actions grid */
    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Page header: stack vertically */
    .page-header-section {
        flex-direction: column;
        gap: 1rem;
    }

    .page-title h1 {
        font-size: 1.375rem;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn-secondary,
    .page-actions .btn-primary {
        flex: 1;
        justify-content: center;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    /* Filters: stack */
    .filters-section {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-section .search-box {
        width: 100%;
        min-width: auto;
    }

    .filter-group {
        width: 100%;
        flex-wrap: wrap;
    }

    .filter-group select {
        flex: 1;
        min-width: 0;
    }

    /* Tables: horizontal scroll */
    .properties-table-container,
    .transactions-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .properties-table,
    .transactions-table {
        min-width: 700px;
    }

    /* Lead & client stats */
    .lead-stats,
    .client-stats,
    .analytics-stats,
    .transaction-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    /* Lead cards: stack */
    .lead-card {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 1rem;
    }

    .lead-actions {
        width: 100%;
        justify-content: flex-start;
    }

    /* Client cards: stack */
    .client-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .client-card .client-actions {
        width: 100%;
        justify-content: flex-start;
    }

    /* Showing cards */
    .showing-card {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Calendar */
    .calendar-day {
        min-height: 60px;
        padding: 0.25rem;
    }

    /* Dashboard cards */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-card {
        padding: 1rem;
        overflow: hidden;
        min-width: 0;
    }

    /* Showing items */
    .showing-item {
        gap: 0.5rem;
    }

    .showing-details {
        min-width: 0;
        flex: 1;
    }

    .showing-details h4 {
        font-size: 0.8125rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .showing-details p {
        font-size: 0.75rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .showing-date {
        width: 42px;
        height: 42px;
        flex-shrink: 0;
    }

    .showing-date .day {
        font-size: 1rem;
    }

    .showing-actions {
        flex-shrink: 0;
    }

    .showing-actions .btn-icon {
        width: 28px;
        height: 28px;
    }

    .showing-actions .btn-icon svg {
        width: 14px;
        height: 14px;
    }

    /* Lead items */
    .lead-item {
        gap: 0.5rem;
    }

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

    .lead-info h4 {
        font-size: 0.8125rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .lead-info p {
        font-size: 0.75rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .lead-avatar img {
        width: 32px;
        height: 32px;
    }

    .btn-contact-lead {
        padding: 0.375rem 0.5rem;
        font-size: 0.6875rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Listings table */
    .listings-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .listings-table table {
        min-width: 420px;
    }

    .listing-cell img {
        width: 40px;
        height: 30px;
    }

    .listing-cell .listing-address {
        font-size: 0.8125rem;
    }

    .listing-cell .listing-price {
        font-size: 0.75rem;
    }

    /* Quick actions grid */
    .actions-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .action-card {
        padding: 0.75rem 0.5rem;
        gap: 0.375rem;
    }

    .action-card svg {
        width: 20px;
        height: 20px;
    }

    .action-card span {
        font-size: 0.6875rem;
    }

    .quick-actions {
        margin-top: 1.25rem;
    }

    /* Stats grid: 2 cols compact */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .stat-content .stat-value {
        font-size: 1.25rem;
    }

    .stat-content .stat-label {
        font-size: 0.75rem;
    }

    .stat-content .stat-change {
        font-size: 0.6875rem;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
    }

    .stat-icon svg {
        width: 18px;
        height: 18px;
    }

    /* Welcome section compact */
    .welcome-content h1 {
        font-size: 1.25rem;
    }

    .btn-add-property {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .page-btn {
        width: 36px;
        height: 36px;
        font-size: 0.8125rem;
    }

    /* Modal: full width on mobile */
    .modal-overlay {
        padding: 0.75rem;
    }

    .modal-dialog {
        max-width: 100%;
        width: 100%;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 1rem;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer .btn-secondary,
    .modal-footer .btn-primary {
        width: 100%;
        justify-content: center;
    }

    /* Marketing page */
    .materials-grid {
        grid-template-columns: 1fr;
    }

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

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

    .marketing-page .checkboxes {
        flex-direction: column;
    }

    .marketing-page .modal-content {
        max-width: 100%;
        margin: 0;
        border-radius: 0.75rem;
    }

    .marketing-page .modal-content.modal-lg {
        max-width: 100%;
    }

    .marketing-page .modal-header {
        padding: 1rem;
    }

    .marketing-page .modal-body {
        padding: 1rem;
    }

    .marketing-page .modal-footer {
        padding: 0.75rem 1rem;
    }

    .marketing-page .filters-bar select {
        min-width: 0;
        flex: 1;
    }

    /* Publish modal */
    .publish-tabs {
        padding: 0 0.75rem;
        overflow-x: auto;
    }

    .publish-tab {
        font-size: 0.8125rem;
        padding: 0.625rem 0.75rem;
        white-space: nowrap;
    }

    .share-url-box {
        flex-direction: column;
    }

    .publish-stats-row {
        gap: 1rem;
    }

    .contact-search {
        width: 100%;
    }

    .manual-email-row {
        flex-direction: column;
    }

    /* Toast: full width on mobile */
    .toast-notification {
        left: 1rem;
        right: 1rem;
        max-width: none;
        bottom: 1rem;
    }

    /* Charts */
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-card.large {
        grid-column: span 1;
    }

    /* Bulk upload */
    .upload-steps {
        flex-direction: column;
    }

    .step-line {
        width: 2px;
        height: 30px;
    }

    .upload-methods {
        grid-template-columns: 1fr;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .agent-content {
        padding: 0.75rem;
    }

    .templates-grid {
        grid-template-columns: 1fr;
    }

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

    .page-actions .btn-secondary,
    .page-actions .btn-primary {
        width: 100%;
    }
}
