@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-dark: #0b0f19;
    --bg-card: rgba(17, 24, 39, 0.6);
    --bg-card-hover: rgba(31, 41, 55, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.4);
    
    /* Brand Colors */
    --color-primary: #6366f1;
    --color-primary-grad: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --color-success: #10b981;
    --color-success-grad: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --color-warning: #f59e0b;
    --color-warning-grad: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --color-danger: #f43f5e;
    --color-danger-grad: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --color-info: #0ea5e9;
    --color-info-grad: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    
    /* Text Colors */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #1f2937;
    
    --transition-speed: 0.3s;
    --border-radius: 16px;
    --shadow-main: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.05) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(244, 63, 94, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header & Navigation Styles */
header {
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 2rem;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.3rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo i {
    background: var(--color-primary-grad);
    -webkit-background-clip: initial;
    -webkit-text-fill-color: white;
    padding: 8px;
    border-radius: 10px;
    font-size: 1.1rem;
}

.role-switcher {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: 30px;
    display: flex;
    gap: 4px;
}

.role-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    gap: 6px;
}

.role-btn.active {
    background: var(--color-primary-grad);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Main Layout */
main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

/* Views (Employee/User vs Admin) */
.view-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
    display: block;
}

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

/* UI Cards Glassmorphism */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-main);
    transition: transform 0.2s ease, border-color var(--transition-speed) ease;
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* Form Controls */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control, select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1rem;
    border-radius: 10px;
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-speed);
}

.form-control:focus, select:focus {
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px var(--border-focus);
}

select option {
    background: #0f172a;
    color: #fff;
    padding: 10px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.85rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary-grad);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5), var(--shadow-glow);
}

.btn-success {
    background: var(--color-success-grad);
    color: #fff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-danger {
    background: var(--color-danger-grad);
    color: #fff;
    box-shadow: 0 4px 14px rgba(244, 63, 94, 0.4);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(244, 63, 94, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* User Attendance View Grid */
.attendance-layout {
    display: grid;
    grid-template-columns: 1.2fr 1.8fr;
    gap: 2rem;
    max-width: 1100px;
    margin: 0 auto;
    transition: all var(--transition-speed);
}

@media (max-width: 992px) {
    .attendance-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Camera Preview Card */
.camera-container {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 4/3;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
}

#camera-stream {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#captured-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
}

.camera-overlay {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 10;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-success);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Location Status Widget */
.location-widget {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.location-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.location-icon {
    font-size: 1.5rem;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
}

.location-icon.verified {
    color: var(--color-success);
    background: rgba(16, 185, 129, 0.1);
}

.location-icon.danger {
    color: var(--color-danger);
    background: rgba(244, 63, 94, 0.1);
}

.location-icon.loading {
    color: var(--color-primary);
    background: rgba(99, 102, 241, 0.1);
    animation: rotate 1.5s linear infinite;
}

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

.location-details h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.location-details p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Admin Dashboard Elements */
.admin-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
}

.admin-sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (max-width: 1024px) {
    .admin-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .admin-sidebar {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 8px;
        white-space: nowrap;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
        gap: 12px;
    }
    
    .admin-sidebar::-webkit-scrollbar {
        height: 4px;
    }
    
    .admin-sidebar::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
    }
}

.admin-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    text-align: left;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.admin-nav-btn.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--color-primary);
    border-left: 3px solid var(--color-primary);
    border-radius: 0 10px 10px 0;
    padding-left: 13px;
}

@media (max-width: 1024px) {
    .admin-nav-btn {
        flex: 0 0 auto;
        padding: 10px 16px;
        text-align: center;
        border-radius: 8px;
    }
    
    .admin-nav-btn.active {
        border-left: none;
        border-bottom: 3px solid var(--color-primary);
        border-radius: 8px;
        padding-left: 16px;
        padding-bottom: 7px;
    }
}

.admin-content-card {
    min-height: 500px;
}

/* Admin Tabs (Stats, Employees, Sessions, Settings) */
.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out forwards;
}

/* Stats Widgets */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-val {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 5px;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-icon {
    font-size: 2rem;
    opacity: 0.3;
}

/* Tables and Data View */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

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

th {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
    background: rgba(244, 63, 94, 0.12);
    color: var(--color-danger);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.badge-info {
    background: rgba(14, 165, 233, 0.12);
    color: var(--color-info);
    border: 1px solid rgba(14, 165, 233, 0.2);
}

/* Photos inside table */
.attendance-photo {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

.attendance-photo:hover {
    transform: scale(1.1);
}

/* Add Item Form styling inside admin */
.inline-form {
    display: flex;
    gap: 12px;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    align-items: flex-end;
}

@media (max-width: 768px) {
    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }
}

.inline-form .form-group {
    margin-bottom: 0;
    flex: 1;
}

/* Modal Dialog */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: #111827;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 100%;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    position: relative;
    text-align: center;
    transform: translateY(20px);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes slideUp {
    to { transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #fff;
}

.success-icon {
    font-size: 4rem;
    color: var(--color-success);
    margin-bottom: 1rem;
    animation: scalePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scalePop {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.modal-body {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.modal-body strong {
    color: #fff;
}

/* Photo Zoom Overlay */
.photo-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1100;
    justify-content: center;
    align-items: center;
}

.photo-overlay img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    border: 3px solid #fff;
    box-shadow: 0 0 30px rgba(255,255,255,0.1);
}

/* Footer styling */
footer {
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    background: rgba(11, 15, 25, 0.9);
    margin-top: 4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ================= RESPONSIVE ADJUSTMENTS FOR ALL DEVICES ================= */

/* Medium Devices (Tablets, max-width: 768px) */
@media (max-width: 768px) {
    main {
        padding: 1.5rem 1rem;
    }
    
    header {
        padding: 1rem;
    }
    
    .logo {
        font-size: 1.15rem;
    }
    
    .logo i {
        padding: 6px;
        border-radius: 8px;
        font-size: 0.95rem;
    }
    
    .role-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .glass-card {
        padding: 1.5rem;
    }
    
    th, td {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    
    .stats-container {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    .stat-val {
        font-size: 1.6rem;
    }
}

/* Small Devices (Mobile, max-width: 576px) */
@media (max-width: 576px) {
    main {
        padding: 1rem 0.75rem;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }
    
    .logo {
        font-size: 1.1rem;
    }
    
    .role-switcher {
        width: 100%;
        justify-content: center;
    }
    
    .role-btn {
        flex: 1;
        justify-content: center;
    }
    
    .glass-card {
        padding: 1.25rem;
        border-radius: 12px;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .attendance-layout div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .attendance-layout .btn {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .camera-container {
        border-radius: 8px;
    }
    
    .modal-content {
        padding: 1.5rem 1rem;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
    
    .success-icon {
        font-size: 3rem;
    }
}

/* Extra Small Devices (Very old or small phones, max-width: 360px) */
@media (max-width: 360px) {
    .logo span {
        font-size: 0.9rem;
    }
}
