/* === Reset & Base === */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #1a1a2e;
    --border: rgba(255, 255, 255, 0.08);
    --border-focus: #6c63ff;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted: #555570;
    --accent: #6c63ff;
    --accent-hover: #5a52d9;
    --accent-glow: rgba(108, 99, 255, 0.25);
    --success: #2dd4a0;
    --success-bg: rgba(45, 212, 160, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(108, 99, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(45, 212, 160, 0.05) 0%, transparent 50%);
}

/* === Layout === */
.app-wrapper {
    width: 100%;
    max-width: 460px;
}

.container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

/* === Header === */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

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

.logo-icon {
    font-size: 1.6rem;
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.server-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--success);
    background: var(--success-bg);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(45, 212, 160, 0.2);
}

.pulse {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* === Status Cards === */
.status-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.status-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-card.last-stop-card {
    grid-column: 1 / -1;
}

.status-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* === Tabs === */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 0.6rem 0.5rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.tab-icon {
    font-size: 0.85rem;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* === Tab Content === */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Inputs === */
.input-group {
    margin-bottom: 1rem;
}

.input-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-field {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition);
    outline: none;
}

.input-field::placeholder {
    color: var(--text-muted);
}

.input-field:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Remove number spinners */
.input-field[type="number"]::-webkit-inner-spin-button,
.input-field[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    line-height: 1.4;
}

/* === API Key === */
.api-key-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.api-key-wrapper .input-field {
    padding-right: 3rem;
    font-size: 0.85rem;
}

.toggle-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.4;
    transition: opacity var(--transition);
    padding: 4px;
}

.toggle-btn:hover {
    opacity: 1;
}

.api-status {
    margin-top: 0.8rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    line-height: 1.4;
    display: none;
    transition: all 0.3s ease;
}

.api-status.success {
    display: block;
    background: var(--success-bg);
    border: 1px solid rgba(45, 212, 160, 0.2);
    color: var(--success);
}

.api-status.error {
    display: block;
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.api-status.loading {
    display: block;
    background: rgba(108, 99, 255, 0.1);
    border: 1px solid rgba(108, 99, 255, 0.2);
    color: var(--accent);
}

/* === Duration Preview === */
.duration-preview {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    transition: all var(--transition);
}

.duration-preview.has-value {
    background: var(--success-bg);
    border-color: rgba(45, 212, 160, 0.2);
    color: var(--success);
}

.duration-preview .stop-time-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.duration-preview .hours-value {
    font-weight: 500;
    color: var(--accent);
}

/* === Checkbox === */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.2rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    border-radius: 4px;
}

/* === Buttons === */
.button-group {
    display: flex;
    gap: 8px;
}

.btn {
    padding: 0.75rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-full {
    width: 100%;
}

.btn-primary {
    background: var(--accent);
    color: white;
    flex: 2;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-warning {
    background: var(--warning);
    color: #1a1a2e;
    flex: 1;
}

.btn-warning:hover {
    background: #d97706;
    transform: translateY(-1px);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    flex: 1;
}

.btn-danger:hover {
    background: var(--danger-bg);
    transform: translateY(-1px);
}

/* === Shared Controls === */
.shared-controls {
    margin-top: 0.5rem;
}

/* === Toast === */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--accent);
    color: white;
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background: var(--danger);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.toast.success {
    background: var(--success);
    color: var(--bg-primary);
    box-shadow: 0 4px 16px rgba(45, 212, 160, 0.3);
}

/* === Footer === */
.footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* === Responsive === */
@media (max-width: 480px) {
    body {
        padding: 12px;
        align-items: flex-start;
    }

    .container {
        padding: 1.5rem;
        border-radius: 16px;
    }

    .button-group {
        flex-wrap: wrap;
    }

    .btn-primary {
        flex: 1 1 100%;
    }

    .btn-warning,
    .btn-danger {
        flex: 1;
    }
}
