/* Mobile-first styles for Excuse Generator */

:root {
    --color-primary: #6366F1;
    --color-primary-dark: #4F46E5;
    --color-primary-light: #818CF8;
    --color-bg: #0F172A;
    --color-surface: #1E293B;
    --color-surface-hover: #334155;
    --color-text: #F8FAFC;
    --color-text-muted: #94A3B8;
    --color-success: #10B981;
    --color-error: #EF4444;
    --color-warning: #F59E0B;
    --color-border: #334155;
    --transition-speed: 0.2s;
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

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

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
}

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

/* Header */
.header {
    text-align: center;
    padding: 20px 0;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* Main content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Sections */
.section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

/* Situacion options grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.option-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    min-height: 90px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.option-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.option-card:active {
    transform: scale(0.98);
}

.option-card.selected {
    border-color: var(--color-primary);
    background: rgba(99, 102, 241, 0.1);
}

.option-emoji {
    font-size: 1.75rem;
}

.option-label {
    font-size: 0.85rem;
    text-align: center;
    color: var(--color-text);
    font-weight: 500;
}

/* Nivel options */
.nivel-options {
    display: flex;
    gap: 8px;
}

.nivel-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    min-height: 80px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.nivel-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.nivel-card:active {
    transform: scale(0.98);
}

.nivel-card.selected {
    border-color: var(--color-primary);
    background: rgba(99, 102, 241, 0.1);
}

.nivel-emoji {
    font-size: 1.5rem;
}

.nivel-label {
    font-size: 0.8rem;
    text-align: center;
    color: var(--color-text);
    font-weight: 500;
}

/* Generate button */
.btn-generate {
    width: 100%;
    min-height: 56px;
    padding: 16px 24px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}

.btn-generate:active:not(:disabled) {
    transform: scale(0.98);
    background: var(--color-primary-dark);
}

.btn-generate:disabled {
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.btn-generate .btn-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-generate.loading .btn-text {
    display: none;
}

.btn-generate.loading .btn-loading {
    display: flex;
}

/* 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); }
}

/* Result section */
.result-section {
    display: none;
    flex-direction: column;
    gap: 16px;
    animation: fadeIn 0.3s ease;
}

.result-section.visible {
    display: flex;
}

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

.result-card {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    padding: 20px;
    border-left: 4px solid var(--color-primary);
}

.result-text {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--color-text);
}

.result-actions {
    display: flex;
    gap: 12px;
}

.btn-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    color: var(--color-text);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-action:active {
    transform: scale(0.98);
    background: var(--color-surface-hover);
}

.btn-action.success {
    background: var(--color-success);
    border-color: var(--color-success);
}

.btn-icon {
    font-size: 1.1rem;
}

/* Error section */
.error-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.error-section.visible {
    display: block;
}

.error-card {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--color-error);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
}

.error-text {
    color: var(--color-error);
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.btn-retry {
    min-height: 44px;
    padding: 10px 24px;
    background: var(--color-error);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-retry:active {
    transform: scale(0.98);
}

/* Footer */
.footer {
    padding: 20px 0;
    text-align: center;
}

.usage-counter {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.usage-counter span {
    color: var(--color-primary-light);
    font-weight: 600;
}

.usage-counter.warning span {
    color: var(--color-warning);
}

.usage-counter.depleted {
    color: var(--color-error);
}

.usage-counter.depleted span {
    color: var(--color-error);
}

.credits {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    opacity: 0.7;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-surface);
    color: var(--color-text);
    padding: 12px 24px;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: transform 0.3s ease;
    font-size: 0.9rem;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-left: 3px solid var(--color-success);
}

.toast.error {
    border-left: 3px solid var(--color-error);
}

/* Desktop adjustments */
@media (min-width: 768px) {
    .container {
        padding: 32px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .option-card:hover:not(.selected) {
        background: var(--color-surface-hover);
    }

    .nivel-card:hover:not(.selected) {
        background: var(--color-surface-hover);
    }

    .btn-generate:hover:not(:disabled) {
        background: var(--color-primary-dark);
    }

    .btn-action:hover {
        background: var(--color-surface-hover);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
