/**
 * Dashboard Layout Styles
 * Uses design-system.css for base variables and components
 */

/* Reset body/html to prevent overflow */
html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    overflow-y: auto !important;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    box-sizing: border-box;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--color-surface-alt);
    border-right: 1px solid var(--color-surface-dark);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: var(--z-sticky);
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.2s ease;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    padding: var(--space-md);
    background: var(--color-primary);
    color: var(--color-text-inverse);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.sidebar-header h1 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-text-inverse);
}

.sidebar-header .zone-count {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--color-accent-light);
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-inverse);
    cursor: pointer;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: background 0.15s;
    line-height: 1;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.15);
}

/* Floating expand button — suspension bar */
.sidebar-expand-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    min-height: 120px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 3px 0 10px rgba(0,0,0,0.25);
    transition: background 0.15s, width 0.15s;
    writing-mode: vertical-lr;
    letter-spacing: 2px;
}

.sidebar-expand-btn:hover {
    background: #143D2B;
    width: 40px;
}

/* Show expand button when sidebar is collapsed */
.sidebar.collapsed ~ .map-container .sidebar-expand-btn,
.dashboard-container > .sidebar-expand-btn {
    /* handled by JS */
}

.sidebar-expand-btn.visible {
    display: flex;
}

.sidebar-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.zone-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

/* Zone items styled in design-system.css */

.no-zones {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: var(--color-text-muted);
    font-style: italic;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--color-surface-dark);
    margin-top: auto;
}

.settings-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

.settings-link:hover {
    background: var(--color-surface);
    color: var(--color-primary);
}

/* Notification Center */
.notification-center {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    font-family: var(--font-body);
}

.notification-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: white;
    border: 2px solid var(--color-primary);
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.notification-toggle:hover {
    background: var(--color-primary);
    color: white;
}

.notification-badge {
    background: #CC7722;
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
}

.notification-toggle:hover .notification-badge {
    background: white;
    color: #CC7722;
}

.notification-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    width: 350px;
    max-height: 400px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    overflow: hidden;
    display: none;
}

.notification-dropdown.show {
    display: block;
}

.notification-header {
    padding: 16px;
    background: var(--color-primary);
    color: white;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-list {
    max-height: 340px;
    overflow-y: auto;
}

.notification-item {
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}

.notification-item:hover {
    background: #f5f5f5;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item-title {
    font-weight: 500;
    color: #1B4332;
    margin-bottom: 4px;
    font-size: 14px;
}

.notification-item-desc {
    font-size: 12px;
    color: #666;
}

.notification-item-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.notification-icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    margin-right: 10px;
    font-size: 12px;
}

.notification-icon.registration {
    background: rgba(27, 67, 50, 0.1);
    color: #1B4332;
}

.notification-icon.water {
    background: rgba(82, 183, 136, 0.2);
    color: #52B788;
}

.no-notifications {
    padding: 40px 20px;
    text-align: center;
    color: #999;
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--color-surface);
    min-height: 0; /* Fix flexbox overflow issue */
}

#map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Fix Leaflet popup overflow */
.leaflet-popup {
    margin-bottom: 0;
}

.leaflet-popup-content-wrapper {
    max-width: 300px;
}

.leaflet-container {
    overflow: hidden;
}

/* Additional popup content styles (extends design-system.css) */
.popup-content h3 {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 600;
}

/* Layer Control Styles (extends Leaflet defaults) */
.leaflet-control-layers-list {
    font-family: var(--font-body);
    font-size: 0.875rem;
}

/* Zone code labels on map */
.zone-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}
.zone-label span {
    color: #fff;
    padding: 2px 10px;
    font-weight: 800;
    font-style: italic;
    font-family: 'DM Sans', sans-serif;
    white-space: nowrap;
    text-shadow: 0 2px 6px rgba(0,0,0,0.7), 0 0 20px rgba(0,0,0,0.4);
    pointer-events: none;
    background: none;
    transition: font-size 0.15s ease;
    transform: translate(-50%, -50%);
    display: inline-block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column-reverse;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        height: 40vh;
        border-right: none;
        border-top: 1px solid var(--color-surface-dark);
    }

    .map-container {
        height: 60vh;
    }

    .zone-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: var(--space-sm);
    }

    .zone-item {
        min-width: 280px;
        margin-bottom: 0;
    }

    .sidebar-header {
        padding: var(--space-md);
    }

    .sidebar-header h1 {
        font-size: 1.25rem;
    }
}