/* ==========================================================================
   THERMATRACK IoT - SQL LOGS MANAGEMENT STYLESHEET (manage_logs.css)
   ========================================================================== */

:root {
    --bg-main: #0a0f1d;
    --bg-card: rgba(15, 23, 42, 0.75);
    --bg-card-hover: rgba(30, 41, 59, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 240, 255, 0.4);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-cyan: #00f0ff;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-blue: #3b82f6;
    
    --font-main: 'Inter', 'Outfit', 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-digit: 'Outfit', 'Inter', monospace;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding: 1.5rem 2rem;
}

/* Background Glowing Orbs */
.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: 
        radial-gradient(circle at 10% 20%, rgba(0, 240, 255, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 90% 80%, rgba(244, 63, 94, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* TOP HEADER */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: 1rem 1.75rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

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

.logo-icon {
    font-size: 2.2rem;
    color: var(--accent-cyan);
    filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.6));
}

.logo-text h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.accent-text {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Page Navigation Switcher */
.page-nav-switcher {
    display: flex;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 99px;
    padding: 4px;
    gap: 4px;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.15rem;
    border-radius: 99px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(139, 92, 246, 0.2));
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 240, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.15);
}

/* Header Status */
.header-status {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.system-time {
    font-family: var(--font-digit);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 1px;
}

/* SUMMARY STATS GRID */
.summary-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    backdrop-filter: blur(10px);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-val {
    font-family: var(--font-digit);
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-primary);
}

.text-cyan { color: var(--accent-cyan) !important; }
.text-emerald { color: var(--accent-emerald) !important; }
.text-rose { color: var(--accent-rose) !important; }
.text-amber { color: var(--accent-amber) !important; }

/* MAIN TABLE CARD */
.main-table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.6);
}

/* TOOLBAR */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.search-filter-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.85rem;
}

.search-input-wrapper {
    position: relative;
    width: 320px;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.95rem;
}

#search-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    padding: 0.6rem 2.2rem 0.6rem 2.6rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}

.btn-clear-search {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-clear-search:hover { color: var(--accent-rose); }
.hidden { display: none !important; }

.filter-select-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.filter-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.filter-select option {
    background: #0f172a;
    color: var(--text-primary);
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.btn-refresh {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.3);
}
.btn-refresh:hover {
    background: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.action-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-print {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border-color: rgba(245, 158, 11, 0.3);
}
.btn-print:hover {
    background: rgba(245, 158, 11, 0.3);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}

.btn-export-excel {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-export-excel:hover {
    background: linear-gradient(135deg, #34d399, #10b981);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

/* DATA TABLE */
.table-responsive-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(10, 15, 29, 0.6);
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.logs-table th {
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.logs-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
    color: var(--text-primary);
}

.logs-table tbody tr {
    transition: background-color 0.15s ease;
}

.logs-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.col-id { font-family: var(--font-digit); color: var(--text-secondary); width: 60px; }
.col-temp { font-family: var(--font-digit); font-weight: 700; font-size: 1.05rem; }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 99px;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pill.pass {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.status-pill.reheat {
    background: rgba(244, 63, 94, 0.18);
    color: #fb7185;
    border: 1px solid rgba(244, 63, 94, 0.35);
}

/* ACTION BUTTONS PER ROW */
.row-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-row-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-edit:hover {
    background: rgba(0, 240, 255, 0.15);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.btn-delete:hover {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border-color: var(--accent-rose);
}

.loading-td {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-secondary);
    font-size: 1rem;
}

.table-footer-info {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* MODAL STYLING */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.glass-modal {
    background: #111827;
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 240, 255, 0.15);
    overflow: hidden;
    animation: modalSlideIn 0.25s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
}
.btn-close-modal:hover { color: var(--accent-rose); }

.edit-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1.5rem;
}

.col-span-2 { grid-column: span 2; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

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

.form-input, .form-select {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.form-select option { background: #0f172a; color: var(--text-primary); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}
.btn-cancel:hover { background: rgba(255, 255, 255, 0.15); color: var(--text-primary); }

.btn-save-modal {
    background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 240, 255, 0.3);
}
.btn-save-modal:hover {
    box-shadow: 0 6px 18px rgba(0, 240, 255, 0.45);
    transform: translateY(-1px);
}

/* TOAST NOTIFICATION */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    animation: toastSlideIn 0.3s ease-out;
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-rose); }

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* PRINT HEADER BANNER HIDDEN BY DEFAULT */
.print-header-banner { display: none; }

/* ==========================================================================
   PRINTER-FRIENDLY STYLES (@media print)
   ========================================================================== */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0 !important;
        font-size: 11pt;
    }

    .glass-bg, .app-header, .table-toolbar, .col-actions, .row-actions,
    .summary-stats-grid, .table-footer-info, .modal-overlay, #toast-container {
        display: none !important;
    }

    .app-container {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
    }

    .main-table-card {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        padding: 0 !important;
    }

    .print-header-banner {
        display: block !important;
        text-align: center;
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
        border-bottom: 2px solid #000000;
    }

    .print-header-banner h2 {
        font-size: 16pt;
        font-weight: 800;
        margin-bottom: 0.25rem;
        color: #000000 !important;
    }

    .print-header-banner p {
        font-size: 10pt;
        color: #444444 !important;
    }

    .table-responsive-wrapper {
        border: none !important;
        overflow: visible !important;
    }

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

    .logs-table th, .logs-table td {
        border: 1px solid #333333 !important;
        padding: 6pt 8pt !important;
        color: #000000 !important;
        background: transparent !important;
    }

    .logs-table th {
        background: #f0f0f0 !important;
        font-weight: 700 !important;
    }

    .status-pill {
        border: none !important;
        background: transparent !important;
        color: #000000 !important;
        font-weight: 700 !important;
    }
}
