/* General Styles */
:root {
    --primary-color: #298004;
    --secondary-color: #d4af37;
    --background-color: #f4f4f4;
    --card-bg-color: #ffffff;
    --text-color: #333;
    --border-color: #ddd;
    --success-color: #298004;
    --error-color: #dc3545;
    --info-color: #17a2b8;
    --warning-color: #ffc107;
}

* {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    height: 100%;
}

/* User Login Screen */
.user-login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #298004 0%, #1a5003 100%);
}

.user-login-card {
    background: var(--card-bg-color);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    text-align: left;
}

/* QR Scanner Card - Wider for scanner */
.user-login-card[style*="max-width: 600px"] {
    max-width: 90vw;
    max-width: min(90vw, 800px);
    padding: 1.5rem;
}

/* QR Reader Container - Responsive */
#qr-reader-container {
    width: 100%;
    max-width: 100%;
    margin: 20px auto;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 10px;
    padding: 15px;
    box-sizing: border-box;
}

/* QR Reader - Responsive */
#qr-reader {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 300px;
    position: relative;
}

/* Ensure html5-qrcode video element is responsive */
#qr-reader video,
#qr-reader canvas {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
}

/* html5-qrcode internal container */
#qr-reader > div {
    width: 100% !important;
    max-width: 100% !important;
}

/* html5-qrcode video container */
#qr-reader video {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
}

/* html5-qrcode canvas overlay */
#qr-reader canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
}

/* Make sure the scanner adapts to viewport */
.user-login-screen {
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.user-login-card h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
}

.user-login-card .form-group {
    text-align: left;
}

/* Container Layout */
.container {
    display: flex;
    min-height: calc(100vh - 50px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, var(--primary-color) 0%, #1a5003 100%);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header .logo {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.sidebar-header .company-info {
    font-size: 0.85rem;
    opacity: 0.8;
}

.sidebar-clock {
    padding: 1rem 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    padding: 0.85rem 1rem;
    background: transparent;
    border: none;
    color: white;
    text-align: left;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.1);
}

.nav-btn.active {
    background: rgba(255,255,255,0.2);
    font-weight: 600;
}

.qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-top: auto;
    padding: 2rem 1rem 1.25rem;
    text-align: center;
}

.qr-section h3 {
    width: 100%;
    margin: 0 0 0.7rem;
    text-align: center;
}

#sidebarQRCodesContainer,
#employeeQRCode {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    text-align: center;
}

.qr-img {
    display: block;
    margin: 0 auto 0.8rem;
}

.qr-name,
.qr-id,
.qr-note {
    width: 100%;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: var(--background-color);
}

/* Sections */
.section {
    display: none;
}

.section.active {
    display: block;
}

.section h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--secondary-color);
}

/* Form Styles */
.form-container {
    background: var(--card-bg-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    max-width: 1500px;
}

.form-group {
    margin-bottom: 1.25rem;     
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
    text-align: left;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(41, 128, 4, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-login {
    background-color: var(--success-color);
    color: white;
}

.btn-logout {
    background-color: var(--error-color);
    color: white;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Status Card */
.status-card {
    background: var(--card-bg-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin-top: 1.5rem;
    max-width: 1500px;
}

.status-card h3 {
    color: var(--primary-color);
    margin: 0 0 1rem 0;
}

.current-status {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.status-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 6px;
    font-weight: 500;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
}

/* Dashboard Stats */
.dashboard-top {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    text-align: center;
    border-left: 4px solid var(--primary-color);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    color: #666;
    margin-top: 0.5rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
    background: var(--card-bg-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--primary-color);
}

tbody tr:hover {
    background-color: #f8f9fa;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Active Sessions Card */
.active-sessions-card {
    background: var(--card-bg-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.dtr-logs-card {
    margin-top: 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--card-bg-color);
    box-shadow: var(--panel-shadow);
}

.dtr-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.dtr-card-header p {
    margin: 0.35rem 0 0;
    color: #64748b;
    font-size: 0.95rem;
}

.dtr-refresh-btn {
    flex: 0 0 auto;
    padding: 0.55rem 0.95rem;
    border-radius: 10px;
    background: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
}

.dtr-filter-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.6rem;
}

.dtr-date-input {
    width: 160px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #ffffff;
    color: #1f2937;
    font-weight: 600;
}

.dtr-refresh-btn--secondary {
    background: #e5e7eb;
    color: #374151;
}

.dtr-refresh-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.dtr-empty-state {
    padding: 1rem;
    border-radius: 12px;
    background: #f8fafc;
    color: #64748b;
    text-align: center;
}

.active-sessions-card h3 {
    color: var(--primary-color);
    margin: 0 0 1rem 0;
}

/* Filter Group */
.filter-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-group input,
.filter-group select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.filter-group input {
    flex: 1;
    min-width: 200px;
}

/* Issues Container */
.issues-container {
    background: var(--card-bg-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-bottom: 2rem;
}

/* Issue Categories */
.issue-categories {
    margin-top: 2rem;
}

.issue-categories h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.category-card {
    background: var(--card-bg-color);
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--warning-color);
}

.category-card strong {
    display: block;
    margin-bottom: 0.5rem;
}

.category-card p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

/* Report Filters */
.report-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.report-filters input,
.report-filters select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

/* Report Content */
.report-content,
.attendance-stats {
    background: var(--card-bg-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

.report-content h3,
.attendance-stats h3 {
    color: var(--primary-color);
    margin: 0 0 1rem 0;
}

.report-summary {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

/* Admin Sections */
.admin-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.admin-card {
    background: var(--card-bg-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.admin-card.full-width {
    grid-column: 1 / -1;
}

.admin-card h3 {
    color: var(--primary-color);
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.admin-card .btn {
    margin-top: 0.5rem;
    margin-right: 0.5rem;
}

/* Footer */
.footer {
    background: var(--text-color);
    color: white;
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
}

.footer p {
    margin: 0;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.active,
.status-badge.on-duty {
    background: #d4edda;
    color: #155724;
}

.status-badge.inactive,
.status-badge.off-duty {
    background: #f8d7da;
    color: #721c24;
}

.status-badge.pending {
    background: #e2e3e5;
    color: #383d41;
}

.status-badge.critical {
    background: var(--error-color);
    color: white;
}

.status-badge.warning {
    background: var(--warning-color);
    color: #856404;
}

.status-badge.info {
    background: var(--info-color);
    color: white;
}

.status-badge.resolved {
    background: var(--success-color);
    color: white;
}

/* Auth Controls */
.auth-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.auth-controls .username,
.sidebar-username {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.3;
}

.auth-controls .logout-btn,
.sidebar-logout {
    margin-left: 0.75rem;
    padding: 0.45rem 0.8rem;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.14);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.active {
    background: #d4edda;
    color: #155724;
}

.status-badge.inactive {
    background: #f8d7da;
    color: #721c24;
}

.status-badge.pending {
    background: #e2e3e5;
    color: #383d41;
}

/* Table Styles for Admin */
.table-container {
    background: var(--card-bg-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
    margin-top: 1rem;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
}

.table-container th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--primary-color);
    padding: 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
}

.table-container td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table-container tbody tr:hover {
    background-color: #f8f9fa;
}

.table-container tbody tr:last-child td {
    border-bottom: none;
}

/* Modal Styles */
#workerModal > div {
    max-height: 90vh;
    overflow-y: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .nav-btn {
        flex: 1;
        text-align: center;
        min-width: auto;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .filter-group {
        flex-direction: column;
    }
    
    .report-filters {
        flex-direction: column;
    }
    
    .admin-sections {
        grid-template-columns: 1fr;
    }
    
    /* QR Scanner Responsive */
    .user-login-card {
        padding: 1.5rem;
        max-width: 95vw !important;
    }
    
    .user-login-card h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    #qr-reader-container {
        padding: 10px;
        margin: 15px auto;
        min-height: 250px;
    }
    
    #qr-reader {
        min-height: 250px !important;
    }
}

@media (max-width: 480px) {
    .user-login-card {
        padding: 1rem;
    }
    
    .user-login-card h2 {
        font-size: 1.25rem;
    }
    
    #qr-reader-container {
        padding: 8px;
        margin: 10px auto;
        min-height: 200px;
    }
    
    #qr-reader {
        min-height: 200px !important;
    }
}

@media (max-height: 600px) {
    .user-login-screen {
        align-items: flex-start;
        padding: 20px 0;
        overflow-y: auto;
    }
    
    .user-login-card {
        margin: 20px auto;
    }
    
    #qr-reader-container {
        min-height: 200px;
    }
    
    #qr-reader {
        min-height: 200px !important;
    }
}
