* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== THEME VARIABLES ===== */
:root {
    /* Light Theme (default) */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f5f5;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --input-border: #ddd;
    --success-color: #28a745;
    --danger-color: #e74c3c;
    --warning-color: #ffc107;
    --info-color: #667eea;
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #e4e4e4;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;
    --border-color: #333355;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --card-bg: #16213e;
    --input-bg: #0f3460;
    --input-border: #333355;
    --success-color: #2ecc71;
    --danger-color: #e94560;
    --warning-color: #f39c12;
    --info-color: #667eea;
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    position: relative;
}

/* ===== BACKGROUND VIDEO ===== */
.video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.video-background video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    object-fit: cover;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

[data-theme="dark"] .video-overlay {
    background: rgba(0, 0, 0, 0.7);
}

/* Ensure content appears above video */
.navbar,
main,
.footer {
    position: relative;
    z-index: 2;
}

main {
    flex: 1;
    padding: 3rem 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background-color 0.3s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

.theme-toggle .icon-sun {
    display: inline;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: inline;
}

/* ===== BACKGROUND VIDEO TOGGLE (Admin Only) ===== */
.background-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background-color 0.3s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.background-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.background-toggle .icon-video-on,
.background-toggle .icon-video-off {
    display: inline;
}

/* ===== NAVBAR ===== */
.navbar {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 8px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo a {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.3s;
}

.logo a:hover {
    opacity: 0.9;
}

.nav-menu {
    display: flex;
}

.nav-menu ul {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    align-items: center;
}

.nav-menu li {
    position: relative;
}

.nav-menu a,
.logout-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s, opacity 0.3s;
    display: block;
}

.nav-menu a:hover,
.logout-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 0.95;
}

.logout-link {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
}

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 0.4rem;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background-color: white;
    border-radius: 2px;
    transition: all 0.3s;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

/* ===== HERO SECTION ===== */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    color: white;
    border-radius: 10px;
    margin-bottom: 3rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.hero p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.95;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.3s, box-shadow 0.3s;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary {
    background-color: #fff;
    color: #667eea;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background-color: transparent;
    color: white;
    border: 2px solid white;
}

.btn-secondary:hover {
    background-color: white;
    color: #667eea;
    transform: translateY(-2px);
}

/* ===== FEATURES SECTION ===== */
.features {
    margin: 4rem 0;
}

.features h2 {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: transform 0.3s, box-shadow 0.3s, background-color 0.3s;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .feature-card {
    background: rgba(22, 33, 62, 0.95);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px var(--shadow-color);
}

.feature-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--info-color);
}

.feature-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== FOOTER ===== */
.footer {
    background-color: #2c3e50;
    color: white;
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
}

[data-theme="dark"] .footer {
    background-color: #0a0a1a;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-links {
    margin-top: 1rem;
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.footer-links a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
}

.footer-links a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    /* Navbar Mobile */
    .hamburger {
        display: flex;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        flex-direction: column;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s;
    }

    .nav-menu.active {
        max-height: 500px;
    }

    .nav-menu ul {
        flex-direction: column;
        gap: 0;
        width: 100%;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu a,
    .logout-link {
        display: block;
        width: 100%;
        padding: 1rem;
        border-radius: 0;
        text-align: left;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-container {
        padding: 0 15px;
    }

    /* Hero Mobile */
    .hero {
        padding: 2rem 1rem;
        border-radius: 5px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .cta-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .btn {
        width: 100%;
        padding: 0.75rem 1rem;
    }

    /* Features Mobile */
    .features h2 {
        font-size: 2rem;
    }

    .feature-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Footer Mobile */
    .footer-links {
        gap: 1rem;
    }

    main {
        padding: 1.5rem 0;
    }

    /* Dashboard Mobile */
    .dashboard-container {
        padding: 0 15px;
        margin: 1rem auto;
    }

    .dashboard-header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        margin-bottom: 1.5rem;
    }

    .dashboard-header h1 {
        font-size: 1.5rem;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .stats-card {
        padding: 1.25rem 1rem;
    }

    .stats-card h2 {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .stats-value {
        font-size: 2rem;
    }

    .action-buttons {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .action-btn {
        padding: 0.875rem;
        font-size: 0.95rem;
    }

    /* Quick Check-in Mobile */
    .quick-checkin {
        padding: 1.25rem !important;
        margin-bottom: 1.5rem !important;
    }

    .quick-checkin h2 {
        font-size: 1.1rem !important;
        margin-bottom: 0.75rem !important;
    }

    .quick-checkin-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .quick-checkin-buttons button,
    .quick-checkin-buttons a {
        width: 100%;
        padding: 0.875rem 1rem !important;
        font-size: 0.95rem !important;
        text-align: center;
    }

    /* Progress Table Mobile */
    .progress-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .progress-table th,
    .progress-table td {
        padding: 0.5rem 0.4rem;
        font-size: 0.85rem;
    }

    /* Entry Form Mobile */
    .entry-form,
    .entries-container {
        padding: 0 15px;
    }

    .entry-form .form-group {
        margin-bottom: 1.25rem;
    }

    .radio-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .radio-option {
        padding: 1rem;
    }

    .form-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-buttons button,
    .form-buttons .btn {
        width: 100%;
    }

    .date-navigation {
        flex-direction: row;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .date-nav-btn {
        flex: 1;
        text-align: center;
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    /* Calendar Mobile */
    .calendar-grid {
        gap: 2px;
    }

    .calendar-day {
        padding: 0.4rem;
        font-size: 0.8rem;
        min-height: 45px;
    }

    .calendar-header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .calendar-nav {
        width: 100%;
        justify-content: space-between;
    }

    /* Admin/Users Table Mobile */
    .admin-table,
    .users-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.85rem;
    }

    .admin-table th,
    .admin-table td,
    .users-table th,
    .users-table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .logo a {
        font-size: 1.2rem;
    }

    .nav-menu a,
    .logout-link {
        padding: 0.75rem;
        font-size: 0.95rem;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .hero p {
        font-size: 0.95rem;
    }

    .btn {
        padding: 0.65rem 1rem;
        font-size: 0.95rem;
    }

    .features h2 {
        font-size: 1.5rem;
    }

    .feature-card {
        padding: 1.5rem;
    }

    .feature-card h3 {
        font-size: 1.2rem;
    }

    /* Extra small screen adjustments */
    .dashboard-header h1 {
        font-size: 1.25rem;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stats-card {
        padding: 1rem 0.75rem;
    }

    .stats-card h2 {
        font-size: 0.65rem;
    }

    .stats-value {
        font-size: 1.5rem;
    }

    .stats-card p {
        font-size: 0.75rem;
    }

    .quick-checkin h2 {
        font-size: 1rem !important;
    }

    .quick-checkin-buttons button,
    .quick-checkin-buttons a {
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
    }

    .calendar-day {
        padding: 0.25rem;
        font-size: 0.7rem;
        min-height: 35px;
    }

    .calendar-day .day-number {
        font-size: 0.75rem;
    }

    /* Hide some table columns on very small screens */
    .hide-mobile {
        display: none;
    }
}

/* ===== TOUCH-FRIENDLY IMPROVEMENTS ===== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .action-btn,
    button,
    a.btn {
        min-height: 44px;
        min-width: 44px;
    }

    .nav-menu a,
    .logout-link {
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    /* Remove hover effects on touch devices */
    .feature-card:hover,
    .action-btn:hover,
    .btn:hover {
        transform: none;
    }

    /* Active state for touch feedback */
    .btn:active,
    .action-btn:active,
    button:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* ===== SAFE AREA FOR NOTCHED DEVICES ===== */
@supports (padding: max(0px)) {
    .navbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .footer {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }

    .dashboard-container,
    .entries-container,
    .container {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}

/* ===== REWIRING DAY COUNTER - CIRCULAR WATCH ===== */
.rewiring-clock {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 20px var(--shadow-color);
    margin-bottom: 2rem;
    text-align: center;
    transition: background 0.3s ease;
}

.rewiring-clock-title {
    color: var(--danger-color);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    font-weight: bold;
}

.rewiring-clock-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* Watch Container */
.watch-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
}

.watch-inactive {
    opacity: 0.5;
}

/* Circular Watch Face */
.watch-face {
    position: relative;
    width: 350px;
    height: 350px;
    background: linear-gradient(145deg, var(--bg-tertiary), var(--bg-secondary));
    border-radius: 50%;
    box-shadow: 
        inset 0 0 30px rgba(0, 0, 0, 0.3),
        0 10px 40px var(--shadow-color),
        0 0 0 8px var(--border-color),
        0 0 0 12px var(--bg-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

[data-theme="dark"] .watch-face {
    box-shadow: 
        inset 0 0 40px rgba(0, 0, 0, 0.6),
        0 10px 50px rgba(0, 0, 0, 0.5),
        0 0 0 8px var(--border-color),
        0 0 0 12px var(--bg-secondary);
}

/* Watch Ring (Outer decorative ring) */
.watch-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid var(--danger-color);
    opacity: 0.3;
    animation: pulse-ring 3s infinite;
}

@keyframes pulse-ring {
    0%, 100% {
        transform: scale(0.95);
        opacity: 0.3;
    }
    50% {
        transform: scale(0.98);
        opacity: 0.5;
    }
}

/* Center Display - Days and Time */
.watch-center {
    text-align: center;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    width: 100%;
    min-height: 200px;
}

/* Days Section */
.days-section {
    margin-bottom: 0.25rem;
}

.days-display {
    font-family: 'Eurostile', 'Rajdhani', 'Orbitron', 'Michroma', 'Arial Black', 'Impact', sans-serif;
    font-size: 4.5rem;
    font-weight: 900;
    color: var(--danger-color);
    line-height: 1;
    text-shadow: 
        0 0 20px rgba(233, 69, 96, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.05em;
    filter: drop-shadow(0 0 10px rgba(233, 69, 96, 0.3));
    min-width: 3ch;
    text-align: center;
}

[data-theme="dark"] .days-display {
    text-shadow: 
        0 0 30px rgba(233, 69, 96, 0.8),
        0 0 15px rgba(233, 69, 96, 0.6),
        0 2px 4px rgba(0, 0, 0, 0.5);
}

.days-label {
    font-family: 'Eurostile', 'Rajdhani', 'Orbitron', 'Michroma', 'Arial Black', 'Impact', sans-serif;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-secondary);
    letter-spacing: 0.3em;
    margin-top: 0.15rem;
    text-transform: uppercase;
}

/* Time Display (HH:MM:SS format) */
.time-display {
    font-family: 'Eurostile', 'Rajdhani', 'Orbitron', 'Michroma', 'Arial Black', 'Impact', sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--danger-color);
    letter-spacing: 0.05em;
    text-shadow: 0 0 15px rgba(233, 69, 96, 0.4);
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.2em;
    flex-wrap: wrap;
}

[data-theme="dark"] .time-display {
    text-shadow: 
        0 0 20px rgba(233, 69, 96, 0.7),
        0 0 10px rgba(233, 69, 96, 0.5);
}

.time-group {
    display: inline-flex;
    align-items: baseline;
    gap: 0.2em;
}

.time-value {
    display: inline-block;
    min-width: 2ch;
    width: 2ch;
    text-align: center;
    font-size: 1em;
}

.time-unit {
    font-size: 0.5em;
    font-weight: 600;
    color: var(--text-secondary);
    text-shadow: none;
    letter-spacing: 0.05em;
}

.time-separator {
    display: inline-block;
    margin: 0 0.1em;
    opacity: 0.6;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 49% { opacity: 0.6; }
    50%, 100% { opacity: 0.2; }
}

/* Watch Markers (12, 3, 6, 9 positions) */
.watch-marker {
    position: absolute;
    width: 3px;
    height: 12px;
    background: var(--info-color);
    opacity: 0.6;
}

.watch-marker-12 {
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
}

.watch-marker-3 {
    right: 5px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

.watch-marker-6 {
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
}

.watch-marker-9 {
    left: 5px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

/* Responsive Design for Watch */
@media (max-width: 768px) {
    .watch-face {
        width: 300px;
        height: 300px;
    }

    .days-display {
        font-size: 3.8rem;
    }

    .days-label {
        font-size: 0.75rem;
    }

    .time-display {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .watch-face {
        width: 260px;
        height: 260px;
    }

    .days-display {
        font-size: 3.2rem;
    }

    .days-label {
        font-size: 0.7rem;
    }

    .time-display {
        font-size: 1.1rem;
    }

    .rewiring-clock {
        padding: 1.5rem 1rem;
    }

    .rewiring-clock-title {
        font-size: 1.2rem;
    }

    .rewiring-clock-subtitle {
        font-size: 0.85rem;
        margin-bottom: 1.5rem;
    }

    .watch-center {
        gap: 0.5rem;
        padding: 0.75rem;
    }
}

@media (max-width: 380px) {
    .watch-face {
        width: 230px;
        height: 230px;
    }

    .days-display {
        font-size: 2.8rem;
    }

    .days-label {
        font-size: 0.65rem;
    }

    .time-display {
        font-size: 1rem;
        gap: 0.15em;
    }

    .time-unit {
        font-size: 0.45em;
    }

    .watch-center {
        padding: 0.5rem;
    }
}

/* Animation for active watch */
@keyframes digital-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.95; }
}

.watch-container:not(.watch-inactive) .time-value,
.watch-container:not(.watch-inactive) .days-display {
    animation: digital-flicker 2s infinite;
}
