/* view-records.css - Redesigned Style for Hamonic QC Records Page */
@import url('styles.css');

/* Header Navbar link spacing overrides to fit 8 links on medium screens */
.nav-menu {
    gap: 0.75rem !important;
}

.nav-menu a {
    padding: 8px 10px !important;
    white-space: nowrap !important;
    font-size: 0.95rem !important;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto 4rem; /* Removed 100px top offset because page-header pushes it down */
    padding: 0 2rem;
}

.page-header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 120px 0 80px; /* Big vertical padding matching about.html */
    text-align: center;
    margin-top: 80px; /* Push banner below fixed header */
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(79, 209, 139, 0.12) 0%, transparent 50%);
    pointer-events: none;
}

.page-title {
    font-size: 2.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: white;
}

.page-desc {
    font-size: 1.05rem;
    opacity: 0.85;
}

/* Dashboard Layout Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2.4fr 1fr;
    gap: 2rem;
}

/* Redesigned Premium Cards */
.glass-card {
    background: white;
    border-radius: 16px;
    border: 1.5px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.03);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(79, 209, 139, 0.08);
    border-color: rgba(79, 209, 139, 0.35);
}

.card-title {
    color: #2c3e50;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid rgba(79, 209, 139, 0.15);
    padding-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
    stroke: #4fd18b;
    stroke-width: 2;
}

/* Records Table Styling */
.records-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 0.5rem;
}

.records-table th, .records-table td {
    padding: 1.1rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.records-table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.records-table th:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.records-table th:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.record-row {
    cursor: pointer;
    transition: all 0.2s;
}

.record-row:hover {
    background-color: rgba(79, 209, 139, 0.05);
}

.record-row td {
    color: #334155;
    font-size: 0.95rem;
}

.record-row td strong {
    font-family: monospace;
    font-size: 1.05rem;
    color: #1e293b;
}

/* Status Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.status-badge.pass {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.fail {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-badge.pending {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Action buttons */
.action-icon-btn {
    background: #f8fafc;
    border: 1.5px solid rgba(226, 232, 240, 0.8);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    padding: 8px 14px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.01);
}

.action-icon-btn:hover {
    color: #27ae60;
    border-color: rgba(79, 209, 139, 0.4);
    background-color: rgba(79, 209, 139, 0.06);
    transform: translateY(-1px);
}

.action-icon-btn .btn-icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #64748b;
}

.empty-state-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    filter: grayscale(0.2);
}

.empty-state h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.5rem;
}

/* Stats Summary Cards */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    text-align: center;
    padding: 1.25rem 0.5rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: all 0.2s;
}

.stat-val {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

/* Fast Search Bar */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #475569;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(203, 213, 225, 0.8);
    background: #ffffff;
    color: #1e293b;
    font-size: 0.95rem;
    font-family: 'Kanit', sans-serif;
    outline: none;
    transition: all 0.2s;
}

.form-input:focus {
    border-color: #4fd18b;
    box-shadow: 0 0 0 3px rgba(79, 209, 139, 0.2);
}

.btn-app {
    padding: 0.75rem 1.2rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: 'Kanit', sans-serif;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary-app {
    background: linear-gradient(135deg, #4fd18b 0%, #3ab776 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 209, 139, 0.2);
}

.btn-primary-app:hover {
    background: linear-gradient(135deg, #3ab776 0%, #27ae60 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 209, 139, 0.3);
}

.btn-primary-app .btn-icon {
    width: 16px;
    height: 16px;
    stroke: white;
    stroke-width: 2;
}

/* Modal Styling - Premium Wide read-only modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.active {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    width: 92%;
    max-width: 1050px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
    transform: scale(0.96) translateY(15px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: #ffffff !important;
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.18) !important;
}

.modal-backdrop.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.modal-header h2 {
    color: #1e293b;
    font-size: 1.3rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.modal-close-btn {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1rem;
    color: #ef4444;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: #ef4444;
    color: white;
    transform: rotate(90deg);
}

/* Tabs inside Modal */
.modal-tabs {
    display: flex;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 1.5rem;
    gap: 0.5rem;
}

.modal-tab-btn {
    background: none;
    border: none;
    padding: 1rem 1.25rem;
    font-family: 'Kanit', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-tab-btn:hover {
    color: #4fd18b;
    background: rgba(79, 209, 139, 0.06);
}

.modal-tab-btn.active {
    color: #3ab776;
    font-weight: 600;
}

.modal-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: #3ab776;
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
}

.modal-tab-btn .nav-icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
    background: #f8fafc;
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
    animation: modalTabFadeIn 0.25s ease-out;
}

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

.modal-footer {
    padding: 1rem 2rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: #f8fafc;
}

.modal-body .glass-card {
    background: #ffffff !important;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.01) !important;
    border: 1.5px solid #e2e8f0 !important;
}

.modal-body .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

/* Read only inputs styling in modal */
.modal-body .form-input {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #475569 !important;
    cursor: not-allowed;
}

.modal-body select.form-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Tooltip and triggers */
.field-desc-trigger {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 16px;
    height: 16px;
    background: #eefbf3;
    border: 1px solid #4fd18b;
    border-radius: 50%;
    font-size: 0.7rem;
    color: #27ae60;
    cursor: help;
    font-weight: 700;
    margin-left: 4px;
}

.tooltip-box {
    display: none;
    position: absolute;
    background: #334155;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    width: 240px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    z-index: 3000;
    line-height: 1.4;
    pointer-events: none;
}

.tooltip-box.bottom::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent #334155 transparent;
}

/* T/S Parameters verification table */
.ts-table-container {
    overflow-x: auto;
    margin-top: 0.5rem;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    background: white;
}

.ts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ts-table th, .ts-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.ts-table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
}

.ts-table tr:hover {
    background-color: #f8fafc;
}

.ts-table td.parameter-name {
    font-weight: 600;
    color: #1e293b;
    width: 15%;
}

.ts-table td.parameter-target {
    width: 12%;
    font-weight: 500;
    color: #475569;
}

.ts-table td.parameter-input {
    width: 15%;
}

.ts-table td.parameter-unit {
    width: 10%;
    color: #64748b;
}

.ts-table td.parameter-desc {
    font-size: 0.8rem;
    color: #64748b;
    width: 48%;
}

.ts-table .form-input {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.85rem !important;
    text-align: center;
}

/* T/S Parameter Validation Delta tags */
.delta-val {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    display: block;
    text-align: center;
    width: 100%;
}

.delta-val.good {
    background-color: #d1fae5;
    color: #065f46;
}

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

.delta-val.bad {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Image previews in Modal tabs */
.image-upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.image-slot {
    border: 2px dashed #cbd5e1;
    background: #f8fafc;
    color: #64748b;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    position: relative;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.image-slot input[type="file"] {
    display: none;
}

.slot-svg-icon {
    width: 28px;
    height: 28px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.slot-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.slot-preview {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    object-fit: contain;
    background: #f1f5f9;
    z-index: 10;
}

.slot-remove-btn {
    display: none !important; /* Hide remove buttons in read-only mode */
}

/* Custom confirm backdrop (unused in read-only mode but ported just in case) */
.confirm-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 4000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.confirm-backdrop.active {
    display: flex;
    opacity: 1;
}

.confirm-card {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    transform: scale(0.95);
    transition: transform 0.25s ease;
}

.confirm-backdrop.active .confirm-card {
    transform: scale(1);
}

.confirm-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.confirm-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.confirm-message {
    font-size: 0.95rem;
    color: #64748b;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 0.75rem;
}

.confirm-actions button {
    flex: 1;
    padding: 0.6rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: 'Kanit', sans-serif;
}

.confirm-btn-cancel {
    background: #f1f5f9;
    color: #475569;
}

.confirm-btn-confirm {
    background: #ef4444;
    color: white;
}

/* Table/List visibility toggles */
.desktop-only-table {
    display: block;
}
.mobile-only-list {
    display: none;
}

/* Toast container positioning */
.toast-container {
    position: fixed;
    top: 90px; /* Below navbar */
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
}

.toast {
    background: white;
    border-radius: 10px;
    padding: 0.8rem 1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid #3b82f6;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success { border-left-color: #10b981; }
.toast-warning { border-left-color: #f59e0b; }
.toast-error { border-left-color: #ef4444; }

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    margin-left: auto;
}

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

@media (max-width: 768px) {
    .app-container {
        padding: 0 1rem;
        margin-top: 90px;
    }
    
    .page-title {
        font-size: 1.6rem !important;
        text-align: center;
    }
    
    .page-desc {
        font-size: 0.9rem !important;
        text-align: center;
    }
    
    .glass-card {
        padding: 1.25rem;
    }
    
    .stats-row {
        gap: 0.75rem;
    }
    
    .stat-val {
        font-size: 1.6rem;
    }
    
    .desktop-only-table {
        display: none !important;
    }
    
    .mobile-only-list {
        display: flex !important;
    }
    
    .mobile-record-card {
        background: #f8fafc;
        border: 1px solid rgba(226, 232, 240, 0.8);
        border-radius: 12px;
        padding: 1.25rem 1rem;
        transition: all 0.2s ease;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.01);
        cursor: pointer;
    }
    
    .mobile-record-card:hover {
        border-color: rgba(79, 209, 139, 0.4);
        background: rgba(79, 209, 139, 0.03);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(79, 209, 139, 0.08);
    }
    
    .records-table th, .records-table td {
        padding: 0.8rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .ts-table {
        min-width: 550px;
    }
    
    .ts-table th:nth-child(5),
    .ts-table td.parameter-desc {
        display: none !important;
    }
    
    .modal-content {
        max-height: 94vh;
        width: 96%;
    }
    
    .modal-body {
        padding: 1.25rem 1rem;
    }
    
    /* Premium Horizontal Scrollable Tabs on Mobile */
    .modal-tabs {
        padding: 0 0.5rem;
        overflow-x: auto;
        white-space: nowrap;
        gap: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-tab-btn {
        flex-shrink: 0;
        padding: 0.8rem 0.6rem;
        font-size: 0.8rem;
    }
    
    /* Convert Manage Models Modal columns to Stack Layout on Mobile */
    #manage-models-modal .modal-body {
        grid-template-columns: 1fr !important;
        overflow-y: auto !important;
        max-height: 70vh !important;
    }
    
    #manage-models-modal .modal-body > div:first-child {
        border-right: none !important;
        border-bottom: 1px solid rgba(79, 209, 139, 0.2) !important;
        padding-right: 0 !important;
        padding-bottom: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
}

@media (max-width: 576px) {
    #admin-actions-panel {
        flex-direction: column;
        gap: 0.75rem !important;
        align-items: stretch;
    }
    
    #admin-actions-panel button {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.4rem !important;
    }
    
    .stat-item {
        padding: 0.75rem 0.25rem !important;
    }
    
    .stat-val {
        font-size: 1.25rem !important;
    }
    
    .stat-label {
        font-size: 0.7rem !important;
    }
}
