/* CSS Variables for theming */
:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --text-primary: #333333;
    --text-secondary: #7f8c8d;
    --text-accent: #2c3e50;
    --border-color: #dddddd;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --success-bg: #efe;
    --success-color: #27ae60;
    --error-bg: #fee;
    --error-color: #c0392b;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-accent: #ffffff;
    --border-color: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --success-bg: #1a2f1a;
    --success-color: #4ade80;
    --error-bg: #2f1a1a;
    --error-color: #f87171;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header styles */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    position: relative;
}

header h1 {
    color: var(--text-accent);
    margin-bottom: 10px;
    font-size: 2.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Dark mode toggle */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--bg-primary);
    transform: scale(1.1);
}

/* Main content */
main {
    flex: 1;
}

/* Machine grid - now used as container for sections */
.machine-grid {
    margin: 0 20px 30px 20px;
    padding: 0 10px;
}

/* Container for side-by-side sections */
.machine-sections-container {
    display: flex;
    gap: 30px;
    height: calc(100vh - 200px);
    min-height: 600px;
}

/* Machine sections */
.machine-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allows flex items to shrink below their content size */
}

.left-section {
    border-right: 2px solid var(--border-color);
    padding-right: 15px;
}

.right-section {
    padding-left: 15px;
}

.section-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-accent);
    margin-bottom: 15px;
    text-align: center;
    padding: 10px 0;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.available-count {
    font-size: 0.9rem;
    font-weight: 500;
    color: #27ae60;
    display: flex;
    align-items: center;
    gap: 6px;
}

.available-count::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #27ae60;
    box-shadow: 
        0 0 0 2px rgba(39, 174, 96, 0.3),
        0 0 8px rgba(39, 174, 96, 0.6),
        inset 0 1px 1px rgba(255, 255, 255, 0.3);
    animation: pulse-green 2s infinite;
}

/* Scrollable container for each machine group */
.machine-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 5px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.machine-scroll-container::-webkit-scrollbar {
    width: 8px;
}

.machine-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

.machine-scroll-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.machine-scroll-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Machine group layout */
.machine-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    min-width: 100%;
    padding: 5px;
}

/* For smaller screens, make it horizontally scrollable */
@media (max-width: 1200px) {
    .machine-group {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .machine-group {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 15px;
        padding-bottom: 10px;
    }
    
    .machine-group .machine-card {
        flex: 0 0 180px;
        min-width: 180px;
    }
}

/* No machines message */
.no-machines {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    grid-column: 1 / -1;
}

.machine-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s ease;
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
}

.machine-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-hover);
}

.machine-card.available {
    cursor: default;
}

.machine-card.in-use {
    cursor: default;
    opacity: 0.9;
}

.machine-card.in-use:hover {
    background-color: var(--bg-primary);
    opacity: 1;
}

.machine-card.available:hover {
    background-color: var(--bg-primary);
}

/* LED Status Indicator */
.machine-card::before {
    content: '';
    position: absolute;
    top: 15px;
    right: 15px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.machine-card.available::before {
    background: #27ae60;
    box-shadow: 
        0 0 0 2px rgba(39, 174, 96, 0.3),
        0 0 10px rgba(39, 174, 96, 0.6),
        inset 0 1px 1px rgba(255, 255, 255, 0.3);
    animation: pulse-green 2s infinite;
}

.machine-card.in-use::before {
    background: #e74c3c;
    box-shadow: 
        0 0 0 2px rgba(231, 76, 60, 0.3),
        0 0 10px rgba(231, 76, 60, 0.6),
        inset 0 1px 1px rgba(255, 255, 255, 0.3);
    animation: pulse-red 1.5s infinite;
}

/* Pulsating animations */
@keyframes pulse-green {
    0%, 100% {
        box-shadow: 
            0 0 0 2px rgba(39, 174, 96, 0.3),
            0 0 10px rgba(39, 174, 96, 0.6),
            inset 0 1px 1px rgba(255, 255, 255, 0.3);
        opacity: 1;
    }
    50% {
        box-shadow: 
            0 0 0 4px rgba(39, 174, 96, 0.1),
            0 0 20px rgba(39, 174, 96, 0.8),
            inset 0 1px 1px rgba(255, 255, 255, 0.3);
        opacity: 0.8;
    }
}

@keyframes pulse-red {
    0%, 100% {
        box-shadow: 
            0 0 0 2px rgba(231, 76, 60, 0.3),
            0 0 10px rgba(231, 76, 60, 0.6),
            inset 0 1px 1px rgba(255, 255, 255, 0.3);
        opacity: 1;
    }
    50% {
        box-shadow: 
            0 0 0 4px rgba(231, 76, 60, 0.1),
            0 0 20px rgba(231, 76, 60, 0.8),
            inset 0 1px 1px rgba(255, 255, 255, 0.3);
        opacity: 0.8;
    }
}

.machine-name {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-accent);
}

.machine-status {
    font-size: 1rem;
    margin-bottom: 8px;
}

.status-available {
    color: #27ae60;
    font-weight: 500;
}

.status-in-use {
    color: #e74c3c;
    font-weight: 500;
}

.timer-remaining {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e67e22;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Timer setup form */
.timer-setup-form {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px var(--shadow);
    max-width: 500px;
    margin: 0 auto;
    transition: background-color 0.3s ease;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-accent);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.2s, background-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.help-text {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

/* Messages */
.error-message {
    background-color: var(--error-bg);
    color: var(--error-color);
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #e74c3c;
    margin-top: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.success-message {
    background-color: var(--success-bg);
    color: var(--success-color);
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #27ae60;
    margin-top: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Confetti animations */
@keyframes confetti-fall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

@keyframes confetti-burst {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(
            calc((var(--random-x, 0.5) - 0.5) * 200px),
            calc((var(--random-y, 0.5) - 0.5) * 200px)
        ) rotate(720deg) scale(0);
        opacity: 0;
    }
}

/* Responsive adjustments for theme toggle */
@media (max-width: 768px) {
    .theme-toggle {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .machine-grid {
        margin: 0 10px 20px 10px;
        padding: 0;
    }
    
    /* Stack sections vertically on mobile */
    .machine-sections-container {
        flex-direction: column;
        gap: 25px;
        height: auto;
        min-height: auto;
    }
    
    .left-section {
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        padding-right: 0;
        padding-bottom: 20px;
    }
    
    .right-section {
        padding-left: 0;
        padding-top: 0;
    }
    
    .section-title {
        font-size: 1.5rem;
        margin-bottom: 12px;
        padding: 8px 0;
        flex-direction: column;
        gap: 6px;
    }
    
    .available-count {
        font-size: 0.8rem;
    }
    
    .machine-scroll-container {
        max-height: 350px;
        overflow-y: auto;
        padding: 5px 0;
    }
    
    .machine-group {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 0;
    }
    
    .machine-card {
        padding: 16px;
        margin: 0;
        border-radius: 6px;
    }
    
    .machine-name {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }
    
    .machine-status {
        font-size: 0.95rem;
        margin-bottom: 6px;
    }
    
    .timer-remaining {
        font-size: 1rem;
        font-weight: 600;
    }
    
    /* Larger touch targets for mobile */
    .machine-card::before {
        width: 14px;
        height: 14px;
        top: 12px;
        right: 12px;
    }
    
    .timer-setup-form {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    header h1 {
        font-size: 1.8rem;
        margin: 20px 0;
    }
    
    .machine-grid {
        margin: 0 5px 15px 5px;
    }
    
    .machine-sections-container {
        gap: 20px;
    }
    
    .section-title {
        font-size: 1.3rem;
        margin-bottom: 10px;
        padding: 6px 0;
        flex-direction: column;
        gap: 4px;
    }
    
    .available-count {
        font-size: 0.75rem;
    }
    
    .machine-scroll-container {
        max-height: 300px;
    }
    
    .machine-group {
        gap: 10px;
    }
    
    .machine-card {
        padding: 14px;
        border-radius: 5px;
    }
    
    .machine-name {
        font-size: 1.1rem;
        margin-bottom: 6px;
    }
    
    .machine-status {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }
    
    .timer-remaining {
        font-size: 0.95rem;
    }
    
    .timer-setup-form {
        padding: 15px;
    }
}

