/* Modern CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Content */
.content {
    padding: 2rem;
}

/* Alarm Section Styles */
.alarm-section {
    margin: 2rem 0;
    display: grid;
    gap: 1rem;
}

.alarm-item {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid;
    transition: all 0.3s ease;
}

.alarm-normal {
    background-color: #f0f9ff;
    border-color: #22c55e;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.1);
}

.alarm-active {
    background-color: #fef2f2;
    border-color: #ef4444;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
    animation: pulse-alarm 2s infinite;
}

@keyframes pulse-alarm {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.alarm-icon {
    font-size: 2rem;
    margin-right: 1rem;
    min-width: 3rem;
    text-align: center;
}

.alarm-details h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.alarm-details p {
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.alarm-warning {
    color: #dc2626;
    font-weight: 600;
    display: block;
    margin-top: 0.5rem;
}

/* Compact Alarm Styles */
.alarm-compact {
    display: grid;
    gap: 0.5rem;
    margin: 1rem 0;
}

.alarm-item-compact {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.alarm-item-compact.alarm-normal {
    background-color: #f8fffe;
    border-color: #22c55e;
    box-shadow: 0 1px 3px rgba(34, 197, 94, 0.08);
}

.alarm-item-compact.alarm-active {
    background-color: #fefafa;
    border-color: #ef4444;
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.15);
    animation: pulse-alarm-compact 2s infinite;
}

@keyframes pulse-alarm-compact {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.01); }
}

.alarm-icon-compact {
    font-size: 1.2rem;
    margin-right: 0.75rem;
    min-width: 1.5rem;
    text-align: center;
}

.alarm-content-compact {
    flex: 1;
    line-height: 1.4;
}

.alarm-content-compact strong {
    color: #1f2937;
    font-weight: 600;
}

.alarm-content-compact small.alarm-warning {
    color: #dc2626;
    font-weight: 500;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Configuration Page Styles */
.config-form {
    max-width: 800px;
    margin: 0 auto;
}

.config-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.config-section h2 {
    color: #1f2937;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.section-description {
    color: #6b7280;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

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

.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
    transform: scale(1.2);
}

.help-text {
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.config-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #e2e8f0;
}

.flash-message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.flash-success {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #10b981;
}

.flash-error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.flash-info {
    background-color: #eff6ff;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

.flash-warning {
    background-color: #fffbeb;
    color: #92400e;
    border: 1px solid #f59e0b;
}

/* Typography */
h1 {
    color: #2d3748;
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
}

h2 {
    color: #4a5568;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

p {
    margin-bottom: 1rem;
    color: #666;
}

/* Buttons */
button, .btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    margin: 0.25rem;
    height: auto;
    line-height: 1.4;
    vertical-align: middle;
}

button:hover, .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.4);
}

button:active, .btn:active {
    transform: translateY(0);
}

/* Danger button */
.btn-danger {
    background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
}

.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.4);
}

/* Success button */
.btn-success {
    background: linear-gradient(135deg, #68d391 0%, #38a169 100%);
}

.btn-success:hover {
    box-shadow: 0 4px 12px rgba(56, 161, 105, 0.4);
}

/* Warning button */
.btn-warning {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #1f2937;
}

.btn-warning:hover {
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Navigation */
.nav-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.nav-buttons form {
    display: inline-block;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
}

/* Forms */
form {
    background: #f8fafc;
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin: 1rem 0;
}

label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

input[type="text"], input[type="password"], textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: white;
}

input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

tr:hover {
    background: #f8fafc;
}

tr:last-child td {
    border-bottom: none;
}

/* Lists */
ul {
    list-style: none;
}

li {
    background: white;
    margin: 1rem 0;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-left: 4px solid #667eea;
}

li ul {
    margin: 0.5rem 0;
    padding-left: 1rem;
}

li li {
    background: transparent;
    box-shadow: none;
    border: none;
    padding: 0.25rem 0;
    margin: 0.25rem 0;
    border-radius: 0;
}

/* Device info */
.device-info {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 12px;
    margin: 1rem 0;
    border: 1px solid #e2e8f0;
}

.device-info p {
    margin: 0.5rem 0;
    font-size: 1rem;
}

.device-info strong {
    color: #374151;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin: 1rem 0;
}

/* AI Insights */
.ai-insights {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
}

pre {
    background: #1a202c;
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header {
        padding: 1.5rem;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .content {
        padding: 1.5rem;
    }
    
    .nav-buttons {
        flex-direction: column;
    }
    
    button, .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    table, th, td {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.75rem 0.5rem;
    }
}

/* Utility classes */
.text-center {
    text-align: center;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

/* Login Form Styles */
.login-form-container {
    max-width: 400px;
    margin: 2rem auto;
    text-align: center;
}

.login-form {
    background: #f8fafc;
    padding: 2.5rem;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.login-btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}

.login-info {
    background: #e6fffa;
    border: 1px solid #4fd1c7;
    border-radius: 12px;
    padding: 1.5rem;
    color: #234e52;
}

.login-info p {
    margin: 0.5rem 0;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 2rem;
}

.flash-message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}

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

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

.flash-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Logout Button */
.logout-btn {
    background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    margin-left: auto;
}

.logout-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(245, 101, 101, 0.4);
}
