/* ============================================
   Reset & Base Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    
    /* LED Colors - Merah=Kualitas, Kuning=Mesin, Hijau=Material/Proses */
    --quality-red: #dc2626;
    --machine-yellow: #f59e0b;
    --process-green: #10b981;
    
    /* Background */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    
    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Border */
    --border-color: #334155;
    
    /* Shadow */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   Header
   ============================================ */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo i {
    font-size: 2rem;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.connection-status i {
    font-size: 0.75rem;
    color: var(--danger-color);
    animation: pulse 2s infinite;
}

.connection-status.connected i {
    color: var(--success-color);
    animation: none;
}

.current-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    padding: 2rem 0;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
}

.section-title i {
    color: var(--primary-color);
}

/* ============================================
   Stats Cards
   ============================================ */
.stats-section {
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.stat-icon.quality {
    background: rgba(220, 38, 38, 0.2);
    color: var(--quality-red);
}

.stat-icon.machine {
    background: rgba(245, 158, 11, 0.2);
    color: var(--machine-yellow);
}

.stat-icon.process {
    background: rgba(16, 185, 129, 0.2);
    color: var(--process-green);
}

.stat-icon.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info-color);
}

.stat-info {
    flex: 1;
}

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   Stations Grid
   ============================================ */
.stations-section {
    margin-bottom: 2rem;
}

.stations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.station-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.station-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.station-card.active {
    border-color: var(--danger-color);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.station-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.station-id {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.station-status {
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.station-status.idle {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-secondary);
}

.station-status.quality {
    background: rgba(220, 38, 38, 0.2);
    color: var(--quality-red);
}

.station-status.machine {
    background: rgba(245, 158, 11, 0.2);
    color: var(--machine-yellow);
}

.station-status.process {
    background: rgba(16, 185, 129, 0.2);
    color: var(--process-green);
}

.station-indicators {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.led-indicator {
    flex: 1;
    height: 60px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.led-indicator.off {
    background: rgba(51, 65, 85, 0.5);
    border-color: var(--border-color);
    opacity: 0.3;
}

.led-indicator.quality {
    background: rgba(220, 38, 38, 0.3);
    border-color: var(--quality-red);
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.5);
    animation: blink 1s infinite;
}

.led-indicator.machine {
    background: rgba(245, 158, 11, 0.3);
    border-color: var(--machine-yellow);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
    animation: blink 1s infinite;
}

.led-indicator.process {
    background: rgba(16, 185, 129, 0.3);
    border-color: var(--process-green);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
    animation: blink 1s infinite;
}

.station-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.station-duration {
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
    font-weight: 600;
}

.buzzer-status {
    padding: 0.5rem;
    background: rgba(245, 158, 11, 0.2);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--machine-yellow);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.buzzer-status i {
    animation: pulse 1s infinite;
}

/* ============================================
   Charts Section
   ============================================ */
.charts-section {
    margin-bottom: 2rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.chart-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.chart-title i {
    color: var(--primary-color);
}

.chart-card canvas {
    max-height: 300px;
}

/* ============================================
   Activity Section
   ============================================ */
.activity-section {
    margin-bottom: 2rem;
}

.activity-list {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item:hover {
    background: var(--bg-hover);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.activity-icon.quality {
    background: rgba(220, 38, 38, 0.2);
    color: var(--quality-red);
}

.activity-icon.machine {
    background: rgba(245, 158, 11, 0.2);
    color: var(--machine-yellow);
}

.activity-icon.process {
    background: rgba(16, 185, 129, 0.2);
    color: var(--process-green);
}

.activity-icon.reset {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-secondary);
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.activity-details {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    white-space: nowrap;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

/* ============================================
   Settings Button
   ============================================ */
.settings-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 99;
}

.settings-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

/* ============================================
   Back Button (for demo dashboard)
   ============================================ */
.back-btn {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 99;
}

.back-btn:hover {
    background: var(--bg-hover);
    transform: translateX(-5px);
    border-color: var(--primary-color);
}

.back-btn i {
    font-size: 1rem;
}

/* ============================================
   Animations
   ============================================ */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ============================================
   Scrollbar
   ============================================ */
.activity-list::-webkit-scrollbar {
    width: 8px;
}

.activity-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.activity-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.activity-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stations-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-card canvas {
        max-height: 250px;
    }
}

/* ============================================
   Landscape Notification
   ============================================ */
.landscape-notification {
    display: none;
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    z-index: 99;
    padding: 0 15px;
    animation: slideDown 0.3s ease;
}

.landscape-notification.show {
    display: block;
}

.landscape-notification.hide {
    animation: slideUp 0.3s ease forwards;
}

.notification-content {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(100, 116, 139, 0.95));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    color: white;
}

.notification-content i.fa-mobile-alt {
    font-size: 1.5rem;
    color: white;
    animation: rotate 2s ease-in-out infinite;
    flex-shrink: 0;
}

.notification-text {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.5;
}

.notification-text strong {
    font-weight: 600;
}

.notification-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    flex-shrink: 0;
}

.notification-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.notification-close i {
    font-size: 0.875rem;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

@keyframes rotate {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-90deg);
    }
    75% {
        transform: rotate(90deg);
    }
}

/* Hide notification on landscape mode */
@media (orientation: landscape) and (max-width: 768px) {
    .landscape-notification {
        display: none !important;
    }
}

/* Show notification only on mobile portrait */
@media (orientation: portrait) and (max-width: 768px) {
    .landscape-notification {
        display: block;
    }
}

/* Hide on desktop */
@media (min-width: 769px) {
    .landscape-notification {
        display: none !important;
    }
}

