/* Global Styles */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
}

body {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.bg-gradient-primary {
    background: var(--primary-gradient) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Stats Cards */
.stat-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.stat-details h6 {
    margin: 0;
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-details h3 {
    margin: 5px 0 0 0;
    font-size: 1.8rem;
    font-weight: 700;
    color: #2c3e50;
}

/* Relay Cards */
.relay-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    border-left: 5px solid #667eea;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.relay-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.relay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.relay-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.relay-state-badge {
    padding: 8px 20px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.relay-state-on {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.relay-state-off {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.relay-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mode-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.mode-btn.active {
    border-color: currentColor;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Routines Section */
.routines-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
}

.routine-item {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 12px;
    border-left: 4px solid var(--success-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.routine-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateX(5px);
}

.routine-item.disabled {
    opacity: 0.5;
    border-left-color: #6c757d;
}

.routine-time {
    display: flex;
    gap: 15px;
    align-items: center;
    font-weight: 600;
    color: #2c3e50;
}

.routine-time i {
    color: var(--success-color);
}

/* Modal Styles */
.modal-content {
    border-radius: 15px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    border-radius: 15px 15px 0 0;
    border-bottom: none;
}

/* Routine Input Group */
.routine-input-group {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.routine-input-group:hover {
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.1);
}

.routine-input-group.disabled {
    opacity: 0.6;
    background: #f8f9fa;
}

/* Time Inputs */
.time-input {
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.time-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

/* Buttons */
.btn {
    border-radius: 10px;
    padding: 10px 20px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Pulse Animation for Active States */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

.relay-state-on {
    animation: pulse 2s infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    .stat-card {
        flex-direction: column;
        text-align: center;
    }
    
    .relay-controls {
        flex-direction: column;
    }
    
    .mode-btn {
        width: 100%;
    }
    
    .routine-item {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* Card Styles */
.card {
    border-radius: 15px;
    border: none;
    overflow: hidden;
}

.card-header {
    border-bottom: none;
    padding: 15px 20px;
    font-weight: 600;
}

/* Alert Styles */
.alert {
    border-radius: 10px;
    border: none;
}

/* Switch Toggle */
.form-check-input {
    cursor: pointer;
    width: 3em;
    height: 1.5em;
}

.form-check-input:checked {
    background-color: var(--success-color);
    border-color: var(--success-color);
}
