* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Login Page */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e1e1;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

button:hover {
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.message {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    text-align: center;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Dashboard */
.header {
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header h1 {
    color: #333;
    font-size: 28px;
}

.header button {
    width: auto;
    padding: 10px 20px;
    background: #dc3545;
}

.header-status-row {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.status-text {
    color: #666;
    font-size: 14px;
}

.status-btn {
    padding: 4px 12px;
    font-size: 12px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.wifi-btn {
    background: #667eea;
}

.update-btn {
    background: #28a745;
}

.delete-btn {
    background: #ff6b6b;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.device-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.device-card:hover {
    transform: translateY(-4px);
}

.device-card h3 {
    color: #333;
    margin-bottom: 12px;
    font-size: 20px;
}

.device-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.device-status.online {
    background: #d4edda;
    color: #155724;
}

.device-status.offline {
    background: #f8d7da;
    color: #721c24;
}

.device-info {
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
}

.device-actions {
    margin-top: 16px;
}

.device-actions button {
    width: 100%;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Pixel Controller */
.pixel-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 10px;
    margin: 30px 0;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.pixel {
    aspect-ratio: 1;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}

.pixel:hover {
    transform: scale(1.1);
    z-index: 10;
}

.pixel.on {
    border-color: #333;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.pixel-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 600;
    color: #333;
    text-shadow: 0 0 3px white;
}

.controls {
    background: white;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.controls h3 {
    margin-bottom: 16px;
    color: #333;
}

.control-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.control-row button {
    flex: 1;
    min-width: 120px;
}

.color-palette {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.color-btn {
    width: 50px;
    height: 50px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: #333;
}

.groups-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.group-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-item button {
    width: auto;
    padding: 8px 16px;
    margin-left: 8px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    width: auto;
    padding: 0;
    color: #666;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: white;
    font-size: 18px;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid #667eea;
}

.toast.success {
    border-left-color: #28a745;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast.info {
    border-left-color: #17a2b8;
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: #28a745;
}

.toast.error .toast-icon {
    color: #dc3545;
}

.toast.warning .toast-icon {
    color: #ffc107;
}

.toast.info .toast-icon {
    color: #17a2b8;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.toast-message {
    font-size: 14px;
    color: #666;
}

.toast-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: auto;
    line-height: 1;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #333;
    transform: none;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.hiding {
    animation: slideOut 0.3s ease-in forwards;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    /* Header responsive fixes */
    .header {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }

    .header h1 {
        font-size: 22px;
    }

    .header-actions {
        flex-direction: column;
        width: 100%;
    }

    .header-actions button {
        width: 100%;
    }

    .header-status-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .status-btn {
        width: 100%;
    }

    /* Device grid responsive */
    .devices-grid {
        grid-template-columns: 1fr;
    }

    /* Pixel grid responsive - reduce columns on mobile */
    .pixel-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
        padding: 16px;
    }

    /* Controls responsive */
    .controls {
        padding: 16px;
    }

    /* Modal responsive */
    .modal-content {
        width: 95%;
        padding: 20px;
    }

    /* Toast notifications on mobile */
    .toast-container {
        right: 10px;
        left: 10px;
        top: 10px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }

    /* Groups section responsive */
    .groups-section {
        padding: 16px;
    }

    .group-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .group-item button {
        width: 100%;
        margin-left: 0;
    }

    /* Schedule items responsive */
    .group-item > div:last-child {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .group-item > div:last-child button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    /* Extra small devices */
    .header h1 {
        font-size: 20px;
    }

    .pixel-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
        padding: 12px;
    }

    .pixel-number {
        font-size: 10px;
    }

    .color-btn {
        width: 40px;
        height: 40px;
    }

    /* Smaller padding on very small screens */
    .controls, .groups-section {
        padding: 12px;
    }
}
