/**
 * TempGuard Dashboard - Main Stylesheet
 * Clean, professional design for admin and client portals
 */

/* ===== CSS Variables ===== */
:root {
    /* Colors */
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --secondary: #6b7280;

    /* Status Colors */
    --status-online: #10b981;
    --status-warning: #f59e0b;
    --status-offline: #ef4444;

    /* Grays */
    --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;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--gray-900);
    background-color: var(--gray-50);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== Login Page ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: var(--spacing-lg);
}

.login-box {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.login-header h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
    margin-bottom: var(--spacing-sm);
}

.login-header p {
    color: var(--gray-600);
    font-size: 0.95rem;
}

.login-footer {
    text-align: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--gray-200);
}

/* ===== Top Header ===== */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-xl);
    z-index: 100;
}

.header-left h1 {
    font-size: 1.25rem;
    color: var(--primary);
}

.header-subtitle {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-left: var(--spacing-sm);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.system-time {
    color: var(--gray-700);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--gray-100);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
}

.system-time #timeDisplay {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--primary);
}

.user-info {
    color: var(--gray-700);
    font-size: 0.95rem;
}

.notification-bell {
    position: relative;
    font-size: 1.25rem;
    cursor: pointer;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -10px;
    background: var(--danger);
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: white;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    z-index: 50;
}

.sidebar-nav {
    padding: var(--spacing-lg) 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-xl);
    color: var(--gray-700);
    transition: all 0.2s;
    position: relative;
}

.nav-item:hover {
    background: var(--gray-50);
    text-decoration: none;
}

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

.nav-icon {
    font-size: 1.25rem;
    margin-right: var(--spacing-md);
}

.nav-text {
    flex: 1;
}

.nav-badge {
    background: var(--danger);
    color: white;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* ===== Main Content ===== */
.dashboard-container {
    display: flex;
    padding-top: var(--header-height);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--spacing-xl);
    min-height: calc(100vh - var(--header-height));
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-xl);
}

.page-header h1 {
    font-size: 1.875rem;
    color: var(--gray-900);
}

.page-header p {
    color: var(--gray-600);
    margin-top: var(--spacing-xs);
}

.page-header-actions {
    display: flex;
    gap: var(--spacing-md);
}

/* ===== Statistics Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.stats-grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.stat-icon-primary { background: rgba(37, 99, 235, 0.1); }
.stat-icon-success { background: rgba(16, 185, 129, 0.1); }
.stat-icon-danger { background: rgba(239, 68, 68, 0.1); }
.stat-icon-warning { background: rgba(245, 158, 11, 0.1); }
.stat-icon-info { background: rgba(59, 130, 246, 0.1); }

.stat-content h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-content p {
    color: var(--gray-600);
    font-size: 0.875rem;
}

/* ===== Cards ===== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-lg);
}

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

.card-header h2 {
    font-size: 1.25rem;
    color: var(--gray-900);
}

.card-body {
    padding: var(--spacing-xl);
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: var(--spacing-lg);
}

/* ===== Stations Grid ===== */
.stations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--spacing-lg);
}

.station-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.station-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.station-card-alert {
    border: 2px solid var(--danger);
}

.station-header {
    padding: var(--spacing-lg);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.station-header h3 {
    font-size: 1.125rem;
    color: var(--gray-900);
}

.station-status {
    font-size: 0.875rem;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 500;
}

.status-online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--status-online);
}

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

.status-offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--status-offline);
}

.station-body {
    padding: var(--spacing-xl);
}

.temp-display {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.temp-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--gray-900);
}

.temp-alert .temp-value {
    color: var(--danger);
}

.station-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--gray-100);
}

.info-label {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.info-value {
    color: var(--gray-900);
    font-weight: 500;
    font-size: 0.875rem;
}

.station-footer {
    padding: var(--spacing-lg);
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.station-no-data {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--gray-500);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    color: var(--gray-700);
    font-weight: 500;
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border-color 0.2s;
}

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

.form-row {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

.filter-form {
    margin: 0;
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-500);
    color: white;
}

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

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

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

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary { background: rgba(37, 99, 235, 0.1); color: var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-info { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.badge-secondary { background: rgba(107, 114, 128, 0.1); color: var(--secondary); }

/* ===== Tables ===== */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--gray-50);
}

.table th {
    padding: var(--spacing-md) var(--spacing-lg);
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}

.table td {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--gray-100);
}

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

/* ===== Alerts ===== */
.alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #1e3a8a;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-xl);
}

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

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mb-3 { margin-bottom: var(--spacing-lg); }
.py-5 { padding-top: var(--spacing-xl); padding-bottom: var(--spacing-xl); }

/* ===== Mobile Menu Button ===== */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-700);
    cursor: pointer;
    padding: var(--spacing-sm);
    margin-right: var(--spacing-md);
}

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

/* ===== Mobile Overlay ===== */
.mobile-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
}

/* ===== Responsive Tables ===== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 600px;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex !important;
}

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

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

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--gray-900);
}

.modal-body {
    padding: var(--spacing-lg);
}

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

.close {
    color: var(--gray-400);
    font-size: 1.75rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover,
.close:focus {
    color: var(--gray-700);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-md);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Show mobile menu button */
    .mobile-menu-btn {
        display: block;
    }

    /* Show mobile overlay */
    .mobile-overlay {
        display: block;
    }

    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--shadow-lg);
    }

    /* Show sidebar when active */
    .sidebar.mobile-active {
        transform: translateX(0);
    }

    /* Prevent body scroll when menu open */
    body.mobile-menu-open {
        overflow: hidden;
    }

    /* Adjust main content */
    .main-content {
        margin-left: 0;
    }

    /* Top header adjustments */
    .top-header {
        padding: 0 var(--spacing-md);
    }

    .header-left h1 {
        font-size: 1.1rem;
    }

    .header-subtitle {
        display: none;
    }

    .system-time {
        font-size: 0.8rem;
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .system-time small {
        display: none !important; /* Hide date on mobile */
    }

    .user-info {
        font-size: 0.85rem;
    }

    /* Cards and grids */
    .stats-grid {
        grid-template-columns: 1fr;
    }

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }

    .form-row {
        flex-direction: column;
    }

    /* Tables - enable horizontal scroll */
    .card-body {
        padding: var(--spacing-sm);
    }

    table {
        font-size: 0.85rem;
    }

    table th,
    table td {
        padding: var(--spacing-sm);
    }

    /* Buttons */
    .btn {
        width: 100%;
        justify-content: center;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        margin-bottom: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    .header-right {
        gap: var(--spacing-sm);
    }

    .notification-bell {
        font-size: 1.1rem;
    }

    .card {
        margin-bottom: var(--spacing-md);
    }

    .stat-card-value {
        font-size: 1.75rem;
    }
}
