/* IIS Timelapse Camera Dashboard Styles — Light Corporate Theme */

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

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f6fa;
    color: #333333;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Header */
.header {
    background: #ffffff;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 22px;
    color: #1a56db;
    font-weight: 600;
}

.header .subtitle {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
}

.last-updated {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

/* Summary Stats */
.summary {
    display: flex;
    gap: 16px;
    padding: 20px 24px;
    flex-wrap: wrap;
}

.stat-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 20px;
    min-width: 140px;
    flex: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stat-card .label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 4px;
}

.stat-card .value.total { color: #1a56db; }
.stat-card .value.online { color: #059669; }
.stat-card .value.offline { color: #dc2626; }
.stat-card .value.battery { color: #d97706; }

/* Search & Filter */
.toolbar {
    padding: 0 24px 16px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: #333333;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: #1a56db;
}

.search-input::placeholder {
    color: #9ca3af;
}

.filter-btn {
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: #333333;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: #1a56db;
    color: #1a56db;
}

.filter-btn.active {
    background: #1a56db;
    border-color: #1a56db;
    color: #ffffff;
}

.refresh-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: #1a56db;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.refresh-btn:hover {
    background: #1e40af;
}

/* Camera Grid */
.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 16px;
    padding: 0 24px 24px;
}

/* Camera Card Link */
.camera-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 380px;
    min-width: 0;
}

/* Camera Card */
.camera-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.camera-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.camera-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 16px 10px;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
    height: 52px;
    overflow: hidden;
}

.camera-card .card-header > div {
    min-width: 0;
    flex: 1;
}

.camera-card .camera-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.camera-card .camera-client {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.camera-card .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-badge.online {
    background: rgba(5, 150, 105, 0.1);
    color: #059669;
}

.status-badge.offline {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.status-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.status-badge.online .dot { background: #059669; }
.status-badge.offline .dot { background: #dc2626; }

/* Card Body */
.card-body {
    padding: 10px 16px;
    flex-shrink: 0;
    height: 170px;
    overflow: hidden;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.metric-row + .metric-row {
    border-top: 1px solid #f3f4f6;
}

.metric-label {
    font-size: 12px;
    color: #6b7280;
}

.metric-value {
    font-size: 13px;
    font-weight: 500;
    color: #333333;
}

.metric-value.warning { color: #d97706; }
.metric-value.danger { color: #dc2626; }
.metric-value.good { color: #059669; }

/* Disk Space Progress Bar */
.disk-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.disk-bar {
    flex: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    min-width: 60px;
}

.disk-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.disk-bar-fill.low { background: #059669; }
.disk-bar-fill.medium { background: #d97706; }
.disk-bar-fill.high { background: #dc2626; }

/* Card Footer */
.card-footer {
    padding: 8px 16px;
    background: #f9fafb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #9ca3af;
    flex-shrink: 0;
    height: 34px;
}

.card-footer .error-code {
    color: #dc2626;
    font-weight: 600;
}

.card-footer .location {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Messages (console-style log output) */
.camera-messages {
    padding: 8px 12px;
    font-size: 11px;
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
    color: #d4d4d4;
    background: #1e1e1e;
    border-top: 1px solid #333;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: break-word;
    line-height: 1.4;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

.camera-messages:empty {
    background: #252525;
}

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #1a56db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    margin-top: 16px;
    color: #6b7280;
    font-size: 14px;
}

/* Error State */
.error-container {
    text-align: center;
    padding: 60px 20px;
}

.error-container .error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-container .error-message {
    color: #dc2626;
    font-size: 16px;
    margin-bottom: 12px;
}

.error-container .retry-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    background: #1a56db;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.error-container .retry-btn:hover {
    background: #1e40af;
}

/* Error Code Reference */
.error-ref-section {
    margin: 16px 24px 24px;
}

.error-ref-toggle {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1a56db;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.error-ref-toggle:hover {
    background: #f9fafb;
}

.error-ref-toggle::before {
    content: '\25B6';
    display: inline-block;
    margin-right: 8px;
    font-size: 10px;
    transition: transform 0.2s;
}

.error-ref-section.open .error-ref-toggle::before {
    transform: rotate(90deg);
}

.error-ref-content {
    display: none;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 16px;
}

.error-ref-section.open .error-ref-content {
    display: block;
}

.error-ref-section.open .error-ref-toggle {
    border-radius: 8px 8px 0 0;
}

.error-ref-intro {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 12px;
}

.error-ref-sub {
    font-size: 13px;
    color: #6b7280;
    margin: 16px 0 8px;
    font-weight: 600;
}

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

.error-ref-table th {
    text-align: left;
    padding: 6px 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    color: #374151;
    font-weight: 600;
    font-size: 12px;
}

.error-ref-table td {
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    color: #333333;
}

.error-ref-table tr:hover td {
    background: #f9fafb;
}

/* Overlay Confirm */
.overlay-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.overlay-dialog {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 28px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.overlay-dialog .dialog-message {
    font-size: 15px;
    margin-bottom: 20px;
    line-height: 1.5;
    color: #333333;
}

.overlay-dialog .dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.overlay-dialog .dialog-buttons button {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}

.overlay-dialog .btn-confirm {
    background: #1a56db;
    color: #ffffff;
}

.overlay-dialog .btn-confirm:hover {
    background: #1e40af;
}

.overlay-dialog .btn-cancel {
    background: #f3f4f6;
    color: #374151;
}

.overlay-dialog .btn-cancel:hover {
    background: #e5e7eb;
}

/* Responsive */
@media (max-width: 768px) {
    .header { padding: 14px 16px; }
    .header h1 { font-size: 18px; }
    .error-ref-section { margin: 10px 12px 12px; }
    .error-ref-toggle { font-size: 12px; padding: 10px 12px; }
    .error-ref-content { padding: 12px; }
    .error-ref-table { font-size: 12px; }
    .error-ref-table th, .error-ref-table td { padding: 5px 8px; }
    .header .subtitle { font-size: 12px; }
    .header-top { flex-direction: column; align-items: flex-start; gap: 4px; }
    .last-updated { font-size: 11px; }
    .summary { padding: 10px 12px; gap: 8px; }
    .stat-card { min-width: 100px; padding: 10px 12px; }
    .stat-card .value { font-size: 20px; }
    .toolbar { padding: 0 12px 10px; gap: 8px; }
    .camera-grid {
        grid-template-columns: 1fr;
        padding: 0 12px 12px;
        gap: 10px;
    }
    .camera-card-link {
        height: auto;
        min-width: 0;
    }
    .camera-card {
        border-radius: 8px;
        min-width: 0;
        max-width: 100%;
    }
    .camera-card .card-header {
        height: auto;
        padding: 10px 12px 8px;
    }
    .camera-card .camera-name {
        font-size: 13px;
    }
    .card-body {
        height: auto;
        padding: 6px 12px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 12px;
    }
    .metric-row {
        padding: 3px 0;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 4px;
    }
    .metric-row + .metric-row {
        border-top: none;
    }
    .metric-label {
        font-size: 11px;
    }
    .metric-value {
        font-size: 12px;
        font-weight: 600;
    }
    .camera-messages {
        max-height: 108px;
        flex: none;
        font-size: 10px;
        padding: 6px 10px;
        line-height: 1.3;
        overflow-x: hidden;
    }
    .card-footer {
        height: auto;
        padding: 6px 12px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .header { padding: 12px; }
    .header h1 { font-size: 16px; }
    .summary {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 8px 10px;
    }
    .stat-card {
        min-width: auto;
        padding: 6px 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
    }
    .stat-card .label { font-size: 10px; }
    .stat-card .value {
        font-size: 16px;
        margin-top: 0;
    }
    .toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        padding: 0 10px 8px;
    }
    .search-input {
        min-width: auto;
        width: 100%;
        padding: 8px 10px;
        font-size: 13px;
    }
    .filter-btn {
        padding: 6px 10px;
        font-size: 11px;
        flex: 1;
        text-align: center;
    }
    .refresh-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
    .camera-grid {
        padding: 0 10px 10px;
        gap: 8px;
    }
    .camera-card {
        border-radius: 6px;
        min-width: 0;
        max-width: 100%;
    }
    .camera-card .card-header {
        padding: 8px 10px 6px;
    }
    .camera-card .camera-name {
        font-size: 12px;
    }
    .camera-card .camera-client {
        font-size: 10px;
    }
    .camera-card .status-badge {
        font-size: 10px;
        padding: 3px 8px;
    }
    .card-body {
        padding: 4px 10px;
        grid-template-columns: 1fr 1fr;
        gap: 0 8px;
    }
    .metric-row {
        padding: 2px 0;
    }
    .metric-label {
        font-size: 10px;
    }
    .metric-value {
        font-size: 11px;
    }
    .camera-messages {
        max-height: 96px;
        font-size: 9px;
        padding: 5px 8px;
        overflow-x: hidden;
    }
    .card-footer {
        padding: 5px 10px;
        font-size: 9px;
    }
}
