:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-dark: #1a1a1a;
    --bg-dark-card: #252525;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-light: #e0e0e0;
    --accent: #10b981;
    --accent-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --accent-hover: #059669;
    --accent-light: #d1fae5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #e5e5e5;
    --border-dark: #333333;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.dashboard {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Header */
.top-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px var(--shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.25rem;
}

.icon-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

/* Navigation Tabs */
.nav-tabs {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    gap: 2rem;
}

.nav-tab {
    background: none;
    border: none;
    padding: 1rem 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    position: relative;
    top: 1px;
}

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

.nav-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.nav-tab i {
    font-size: 1.1rem;
}

/* Dashboard Content */
.dashboard-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.dashboard-section {
    margin-bottom: 2rem;
}

.section-header {
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.section-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Search Card */
.search-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 4px var(--shadow);
}

/* Search Mode Toggle */
.search-mode-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.mode-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.mode-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.mode-btn i {
    font-size: 1.1rem;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.form-group {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group label i {
    font-size: 1rem;
    color: var(--accent);
}

.form-group input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--bg-secondary);
}

.form-group input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-primary);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
    width: 100%;
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--bg-secondary);
}

.form-group select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-primary);
}

.required {
    color: var(--danger);
    margin-left: 0.25rem;
}

/* Autocomplete */
.autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 0.25rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 6px var(--shadow);
}

.autocomplete.show {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--bg-primary);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-dropdown {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s;
}

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

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 2px 4px var(--shadow);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-lg);
}

.dashboard-card-full {
    grid-column: 1 / -1;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-primary);
}

.card-header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header h3 i {
    color: var(--accent);
    font-size: 1.25rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.card-content {
    padding: 1.5rem;
}

/* Outage Card */
.outage-card {
    background: var(--bg-dark-card);
    border-left: 4px solid var(--danger);
    border-radius: 8px;
    padding: 1.5rem;
    color: var(--text-light);
}

.outage-card-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-dark);
}

.outage-card-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.outage-card-item strong {
    color: var(--text-light);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.outage-card-item span {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-left: 1.5rem;
}

/* Addresses Grid */
.addresses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.address-group {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.address-group-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--accent);
    font-size: 0.95rem;
}

.address-group-houses {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.house-badge {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Schedule Items */
.schedule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.schedule-item-label {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.schedule-item-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Schedule Tabs */
.schedule-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.schedule-tab {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
    top: 2px;
}

.schedule-tab:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.schedule-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.schedule-tab i {
    font-size: 1.1rem;
}

.schedule-update-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border-radius: 6px;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.schedule-update-info i {
    color: var(--accent);
}

/* Schedule Tables */
.schedule-tables {
    position: relative;
}

.schedule-table-container {
    display: none;
}

.schedule-table-container.active {
    display: block;
}

.schedule-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
}

.schedule-grid-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: var(--bg-secondary);
}

.schedule-grid-table thead {
    background: var(--bg-primary);
}

.schedule-grid-table thead tr,
.schedule-grid-table tbody tr {
    display: table-row;
}

.schedule-grid-table th,
.schedule-grid-table td {
    display: table-cell;
}

.schedule-grid-table th {
    padding: 0;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
    border: 1px solid var(--border);
    vertical-align: bottom;
    position: relative;
}

.time-interval-header {
    text-align: left !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.9rem !important;
    vertical-align: middle !important;
    width: 120px;
    min-width: 120px;
    background: var(--bg-primary) !important;
}

.hour-header {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 70px;
    padding: 0 !important;
    position: relative;
}

.rotated-text {
    display: inline-block;
    transform: rotate(-90deg);
    transform-origin: center;
    white-space: nowrap;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -15px;
    margin-top: -8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    width: 30px;
    text-align: center;
}

.schedule-grid-table tbody td {
    padding: 0;
    text-align: center;
    border: 1px solid var(--border);
    vertical-align: middle;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 60px;
}

.time-interval-label {
    background: var(--bg-primary);
    font-weight: 500;
    color: var(--text-primary);
    padding: 0.75rem 1rem !important;
    text-align: left !important;
    width: 120px;
    min-width: 120px;
}

/* Schedule Cells */
.schedule-cell {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    cursor: pointer;
}

.schedule-cell:hover {
    background: var(--bg-primary) !important;
    opacity: 0.8;
}

.cell-yes {
    background: var(--bg-secondary);
    color: var(--success);
}

.cell-no {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.cell-first,
.cell-mfirst,
.cell-second,
.cell-msecond {
    background: transparent;
    padding: 0;
}

.cell-maybe {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

/* Split cell for 30-minute intervals - vertical split */
.cell-split {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    position: relative;
}

.cell-half {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
}

.cell-half-left {
    border-right: 1px solid var(--border);
}

.cell-half-right {
    border-left: 1px solid var(--border);
}

.cell-half.cell-yes {
    background: var(--bg-secondary);
    color: var(--success);
}

.cell-half.cell-no {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.cell-half i {
    font-size: 0.9rem;
}

.schedule-cell i {
    font-size: 1.25rem;
    position: relative;
    display: block;
}

/* Legend */
.schedule-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.legend-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    position: relative;
}

.legend-yes {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--success);
}

.legend-yes i {
    font-size: 1.1rem;
}

.legend-no {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.legend-first,
.legend-second {
    background: transparent;
    padding: 0;
    width: 24px;
    height: 24px;
}

.legend-split {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.legend-half {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.legend-half-left {
    border-right: 1px solid var(--border);
}

.legend-half-right {
    border-left: 1px solid var(--border);
}

.legend-half.legend-yes {
    background: var(--bg-secondary);
    color: var(--success);
}

.legend-half.legend-no {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.legend-half i {
    font-size: 0.7rem;
}

.outages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.outage-time-slot {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s;
}

.outage-time-slot:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px var(--shadow);
    border-color: var(--accent);
}

.outage-time-slot .time {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.outage-time-slot .status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-secondary);
}

/* Error */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--danger);
    margin-top: 2rem;
}

.error-message i {
    font-size: 1.25rem;
}

/* Footer */
.dashboard-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.dashboard-footer a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

.dashboard-footer a:hover {
    color: var(--accent-hover);
}

/* Utility */
.hidden {
    display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-content {
        padding: 1rem;
    }

    .top-header {
        padding: 1rem;
    }

    .nav-tabs {
        padding: 0 1rem;
        overflow-x: auto;
    }

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

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

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