/* ===================================
   Code Blue PWA - Enhanced Styles
   =================================== */

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --color-blue: #2196F3;
    --color-blue-light: #90CAF9;
    --color-blue-dark: #1565C0;
    --color-green: #4CAF50;
    --color-red: #F44336;
    --color-yellow: #FFC107;
    --border-radius: 16px;
    --border-radius-sm: 12px;
    --transition: all 0.3s ease;
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 30px rgba(33, 150, 243, 0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ===================================
   Screen Layout
   =================================== */

.screen {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
}

.screen.active {
    display: block;
}

.container {
    max-width: 420px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ===================================
   Header
   =================================== */

.header {
    text-align: center;
    padding: 30px 0 20px;
}

.header-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 12px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.header .icon {
    font-size: 56px;
    display: block;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.header h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--color-blue) 0%, var(--color-blue-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.header .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 0.5px;
}

/* ===================================
   Login Form
   =================================== */

.login-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 24px;
    padding: 20px 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input {
    background: var(--bg-secondary);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 18px;
    font-size: 16px;
    color: var(--text-primary);
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.15);
}

.form-group input::placeholder {
    color: var(--text-secondary);
}

.error-text {
    color: var(--color-red);
    font-size: 14px;
    text-align: center;
    padding: 12px;
    background: rgba(244, 67, 54, 0.1);
    border-radius: var(--border-radius-sm);
}

.hidden {
    display: none !important;
}

/* ===================================
   Buttons
   =================================== */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 18px 28px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-blue) 0%, var(--color-blue-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
}

.btn-small {
    padding: 12px 20px;
    font-size: 14px;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===================================
   Status Bar
   =================================== */

.status-bar {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 14px 18px;
    margin-bottom: 24px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.status-value {
    font-weight: 600;
    font-size: 14px;
}

.status-value.online {
    color: var(--color-green);
}

.status-value.offline {
    color: var(--color-red);
}

.status-value.connecting {
    color: var(--color-yellow);
}

/* ===================================
   Zone Selector - Card Style
   =================================== */

.zone-selector {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 30px;
}

.zone-selector-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.zone-selector-header .icon {
    font-size: 20px;
}

.zone-selector-header label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.zone-selector select {
    width: 100%;
    background: var(--bg-secondary);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 16px 20px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23a0a0a0' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 20px;
}

.zone-selector select:focus {
    outline: none;
    border-color: var(--color-blue);
}

/* ===================================
   Trigger Button with Chibi Icon
   =================================== */

.trigger-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
}

.trigger-button {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, var(--color-blue) 0%, var(--color-blue-dark) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow:
        var(--shadow-lg),
        var(--shadow-glow),
        inset 0 -4px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.trigger-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    border-radius: 50%;
}

.trigger-button:hover:not(:disabled) {
    transform: scale(1.03);
    box-shadow:
        0 15px 50px rgba(0, 0, 0, 0.4),
        0 0 50px rgba(33, 150, 243, 0.5),
        inset 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.trigger-button:active:not(:disabled) {
    transform: scale(0.97);
}

.trigger-button:disabled {
    background: linear-gradient(145deg, #555 0%, #444 100%);
    cursor: not-allowed;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.trigger-button:disabled .trigger-icon,
.trigger-button:disabled .trigger-text {
    opacity: 0.5;
}

.trigger-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    z-index: 1;
}

.trigger-text {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 1px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Pulse animation ring */
@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.trigger-button:not(:disabled)::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid var(--color-blue);
    border-radius: 50%;
    animation: pulse-ring 2s ease-out infinite;
}

/* Trigger hint text below button */
.trigger-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 16px;
    margin-bottom: 10px;
}

/* ===================================
   Send Status
   =================================== */

.send-status {
    text-align: center;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    min-height: 52px;
    border-radius: var(--border-radius-sm);
}

.send-status.success {
    color: var(--color-green);
    background: rgba(76, 175, 80, 0.1);
}

.send-status.error {
    color: var(--color-red);
    background: rgba(244, 67, 54, 0.1);
}

/* ===================================
   Footer
   =================================== */

.footer {
    text-align: center;
    padding: 16px 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.footer-actions {
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

/* ===================================
   Modal
   =================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 32px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.modal-content h2 {
    margin-bottom: 16px;
    color: var(--color-blue);
    font-size: 22px;
}

.modal-content p {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.modal-content .zone-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 16px 0;
    padding: 12px;
    background: rgba(33, 150, 243, 0.1);
    border-radius: var(--border-radius-sm);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* ===================================
   Responsive - Desktop
   =================================== */

@media (min-width: 768px) {
    .container {
        max-width: 480px;
        padding: 40px;
    }

    .header .icon {
        font-size: 72px;
    }

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

    .trigger-button {
        width: 240px;
        height: 240px;
    }

    .trigger-icon {
        width: 70px;
        height: 70px;
    }

    .trigger-text {
        font-size: 24px;
    }

    .trigger-subtext {
        font-size: 13px;
    }
}

/* ===================================
   Safe Area (iPhone notch)
   =================================== */

@supports (padding: env(safe-area-inset-top)) {
    .container {
        padding-top: calc(24px + env(safe-area-inset-top));
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
}