/* assets/style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    direction: rtl;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.header h1 {
    color: #667eea;
    font-size: 24px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-logout, .btn-back {
    background: #f44336;
    color: white;
    padding: 8px 20px;
    border-radius: 5px;
    text-decoration: none;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: #d32f2f;
}

.btn-back {
    background: #667eea;
}

.btn-back:hover {
    background: #5568d3;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 14px;
    transition: border 0.3s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: #5568d3;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}

.success-message {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}

/* Devices Grid */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.device-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.device-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.device-header h3 {
    color: #333;
    font-size: 20px;
}

.settings-icon {
    font-size: 24px;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.3s;
}

.settings-icon:hover {
    transform: rotate(90deg);
}

.device-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 5px;
}

.info-row .label {
    font-weight: 600;
    color: #666;
}

.info-row .value {
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-normal {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-high {
    background: #ffebee;
    color: #c62828;
}

.status-low {
    background: #fff3e0;
    color: #ef6c00;
}

.relay-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.relay-on {
    background: #e8f5e9;
    color: #2e7d32;
}

.relay-off {
    background: #e0e0e0;
    color: #616161;
}

.no-data {
    text-align: center;
    padding: 20px;
    color: #999;
    font-style: italic;
}

.no-devices {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 10px;
    color: #999;
}

/* Settings Page */
.settings-box {
    background: white;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    max-width: 600px;
    margin: 0 auto;
}

.settings-box h2 {
    color: #667eea;
    margin-bottom: 10px;
}

.device-code {
    color: #999;
    margin-bottom: 30px;
    font-size: 14px;
}

.settings-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.settings-section:last-of-type {
    border-bottom: none;
}

.settings-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Responsive */
@media (max-width: 768px) {
    .devices-grid {
        grid-template-columns: 1fr;
    }
    
    .header .container {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* استایل‌های قبلی... */

/* Relay Control Switch */
.relay-control {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
}

.relay-switch-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.relay-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.relay-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.relay-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 30px;
}

.relay-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .relay-slider {
    background-color: #4CAF50;
}

input:checked + .relay-slider:before {
    transform: translateX(30px);
}

.relay-status {
    font-weight: bold;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 14px;
}

/* Relay Source */
.relay-source {
    background: #e3f2fd;
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
}

.source-user {
    color: #1976d2;
    font-weight: bold;
}

.source-esp {
    color: #f57c00;
    font-weight: bold;
}

.source-default {
    color: #757575;
}

/* Pending Command */
.pending-command {
    background: #fff3e0;
    border: 2px dashed #ff9800;
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.pending-command .value small {
    color: #666;
    font-size: 12px;
    margin-right: 5px;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.notification-success {
    background: #4CAF50;
}

.notification-error {
    background: #f44336;
}

/* Responsive */
@media (max-width: 768px) {
    .relay-switch-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}
