/* Cooling Portal Styles - Based on webapp design system */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

/* ==================== AUTH PAGES ==================== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
}

.auth-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    margin-bottom: 16px;
}

.auth-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.auth-logo p {
    color: var(--gray-500);
    font-size: 14px;
}

.auth-form h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 24px;
    text-align: center;
}

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--gray-700);
    font-weight: 500;
    font-size: 13px;
}

.form-group label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.2s;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

select.form-control {
    cursor: pointer;
}

.form-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

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

/* Checkbox */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.checkbox-group label {
    margin: 0;
    font-size: 14px;
    color: var(--gray-600);
    cursor: pointer;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.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-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-group {
    display: flex;
    gap: 12px;
}

/* ==================== ALERTS ==================== */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.alert-icon {
    font-size: 18px;
    margin-top: 1px;
}

.alert-content {
    flex: 1;
}

/* ==================== LINKS ==================== */
.auth-links {
    text-align: center;
    margin-top: 24px;
}

.auth-links a {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* ==================== LOADING ==================== */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

.spinner-dark {
    border-color: rgba(0,0,0,0.1);
    border-top-color: var(--primary);
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner-lg {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    background: var(--gray-900);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px;
    border-bottom: 1px solid var(--gray-700);
    margin-bottom: 24px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.logo-text {
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.logo-text span {
    display: block;
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 400;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: var(--gray-400);
    text-decoration: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.nav-item:hover {
    background: var(--gray-800);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item i {
    width: 20px;
    text-align: center;
}


/* ==================== MAIN LAYOUT ==================== */
.main {
    margin-left: 260px;
    min-height: 100vh;
}

.topbar {
    background: white;
    padding: 16px 32px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
}

.topbar-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.content {
    padding: 32px;
}

/* ==================== CARDS ==================== */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h2 i {
    color: var(--primary);
}

.card-body {
    padding: 24px;
}

/* ==================== KPI CARDS ==================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.kpi-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.kpi-icon.efficiency { background: #dbeafe; color: #2563eb; }
.kpi-icon.power { background: #fef3c7; color: #d97706; }
.kpi-icon.cooling { background: #d1fae5; color: #059669; }
.kpi-icon.temperature { background: #fee2e2; color: #dc2626; }

.kpi-body {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
}

.kpi-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.neutral { color: var(--gray-500); }

.kpi-values {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.kpi-latest, .kpi-avg {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 26px;
    font-weight: 700;
    color: var(--gray-900);
}

.kpi-tag {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-400);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.kpi-separator {
    color: var(--gray-300);
    font-size: 24px;
    font-weight: 300;
    align-self: center;
}

.kpi-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kpi-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
}

/* ==================== SITE SELECTOR ==================== */
.site-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-selector select {
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.site-selector select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ==================== USER MENU ==================== */
.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-700);
}

.user-menu-trigger:hover {
    background: var(--gray-200);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    display: none;
    z-index: 100;
    border: 1px solid var(--gray-200);
}

.user-menu-dropdown.show {
    display: block;
}

.user-menu-dropdown a,
.user-menu-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 14px;
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
}

.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover {
    background: var(--gray-50);
}

.user-menu-dropdown hr {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: 4px 0;
}

/* ==================== CHARTS ==================== */
.chart-container {
    position: relative;
    height: 300px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

/* ==================== CHART TOOLBAR ==================== */
.chart-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.chart-toolbar-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 10px;
    font-size: 12px;
    transition: all 0.15s;
}

.chart-toolbar-btn:hover {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

.chart-toolbar-btn.chart-reset-zoom {
    color: #4f46e5;
    border-color: #c7d2fe;
    background: #eef2ff;
}

.chart-toolbar-btn.chart-reset-zoom:hover {
    background: #e0e7ff;
}


/* ==================== EQUIPMENT STATUS ==================== */
.equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.equipment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.equipment-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.equipment-status.running {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.equipment-status.stopped {
    background: var(--gray-400);
}

.equipment-info {
    flex: 1;
}

.equipment-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-800);
}

.equipment-value {
    font-size: 12px;
    color: var(--gray-500);
}

/* ==================== DATA TABLE ==================== */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: var(--gray-50);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-600);
}

.data-table tr:hover td {
    background: var(--gray-50);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* ==================== PAGINATION ==================== */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
}

.pagination-info {
    font-size: 14px;
    color: var(--gray-600);
}

.pagination-controls {
    display: flex;
    gap: 8px;
}

.page-btn {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--gray-700);
}

.page-btn:hover:not(:disabled) {
    background: var(--gray-50);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

/* ==================== DATE PICKER ==================== */
.date-range {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.date-range input[type="date"] {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.date-range input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
}

/* ==================== BADGES ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

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

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

.modal-content {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state i {
    font-size: 48px;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--gray-500);
    font-size: 14px;
}

/* ==================== SECTIONS ==================== */
.page-section {
    display: none;
}

.page-section.active {
    display: block;
}

/* ==================== REFRESH TOGGLE ==================== */
.refresh-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-600);
}

.refresh-toggle input[type="checkbox"] {
    width: 36px;
    height: 20px;
    appearance: none;
    background: var(--gray-300);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-toggle input[type="checkbox"]:checked {
    background: var(--success);
}

.refresh-toggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.2s;
}

.refresh-toggle input[type="checkbox"]:checked::before {
    left: 18px;
}

.last-updated {
    font-size: 12px;
    color: var(--gray-500);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 16px 8px;
    }

    .logo-text, .nav-section-title, .nav-item span {
        display: none;
    }

    .logo {
        justify-content: center;
        padding-bottom: 16px;
    }

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

    .nav-item i {
        width: auto;
    }

    .main {
        margin-left: 80px;
    }

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

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main {
        margin-left: 0;
    }

    .topbar {
        padding: 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .content {
        padding: 16px;
    }

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

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

    .date-range {
        flex-direction: column;
        align-items: stretch;
    }
}

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

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

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mr-2 { margin-right: 8px; }
.ml-2 { margin-left: 8px; }

.fade-in {
    animation: fadeIn 0.3s ease;
}

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