/* ===========================================
   NombreGen - Generador de Nombres
   Mobile-first CSS
   =========================================== */

/* CSS Variables */
:root {
    --color-primary: #6366F1;
    --color-primary-dark: #4F46E5;
    --color-primary-light: #A5B4FC;
    --color-secondary: #F59E0B;
    --color-success: #10B981;
    --color-error: #EF4444;
    --color-bg: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-text: #1F2937;
    --color-text-muted: #6B7280;
    --color-border: #E5E7EB;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --transition-speed: 0.2s;
}

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

/* Base */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

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

/* Container */
.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: 24px 0 16px;
}

.logo {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.tagline {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* Screens */
.screen {
    display: none;
    flex: 1;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Form */
.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
    -webkit-appearance: none;
}

.form-group input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.7;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-group input:invalid:not(:placeholder-shown) {
    border-color: var(--color-error);
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 56px;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed), background-color var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-secondary:hover {
    background: var(--color-primary);
    color: white;
}

.btn-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

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

/* Rate Limit Info */
.rate-limit-info {
    text-align: center;
    padding: 12px;
    margin-top: 16px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    box-shadow: var(--shadow-sm);
}

#remaining-count {
    font-weight: 700;
    color: var(--color-primary);
}

.rate-limit-info.warning {
    background: #FEF3C7;
    color: #92400E;
}

.rate-limit-info.warning #remaining-count {
    color: #D97706;
}

/* Error Message */
.error-message {
    margin-top: 16px;
    padding: 12px 16px;
    background: #FEE2E2;
    color: var(--color-error);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    text-align: center;
}

/* Back Button */
.btn-back {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 1rem;
    font-weight: 500;
    padding: 8px 0;
    cursor: pointer;
    text-align: left;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-back:hover {
    text-decoration: underline;
}

/* Results */
.results-header {
    margin: 16px 0;
}

.results-header h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.results-query {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    padding-bottom: 16px;
}

/* Result Card */
.result-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: box-shadow var(--transition-speed), transform var(--transition-speed);
}

.result-card:hover {
    box-shadow: var(--shadow-md);
}

.result-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.result-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    flex-shrink: 0;
}

.result-name {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
    word-break: break-word;
}

.btn-copy {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.6;
    transition: opacity var(--transition-speed), transform var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-copy:active {
    transform: scale(0.9);
}

.btn-copy.copied {
    opacity: 1;
    color: var(--color-success);
}

.result-explanation {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    padding-left: 36px;
}

/* Results Actions */
.results-actions {
    padding: 16px 0;
    margin-top: auto;
}

/* Limit Screen */
#screen-limit {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 32px;
}

.limit-message {
    background: var(--color-surface);
    padding: 32px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.limit-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
}

.limit-message h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--color-text);
}

.limit-message p {
    color: var(--color-text-muted);
}

/* Footer */
.footer {
    text-align: center;
    padding: 16px 0;
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.footer a {
    color: var(--color-primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

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

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

/* Responsive - Tablet and up */
@media (min-width: 768px) {
    .container {
        padding: 24px;
    }

    .header {
        padding: 32px 0 24px;
    }

    .logo {
        font-size: 2rem;
    }

    .form {
        gap: 20px;
    }

    .form-group input {
        padding: 16px 20px;
    }

    .result-card {
        padding: 20px;
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support (optional, can enable later) */
/*
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0F172A;
        --color-surface: #1E293B;
        --color-text: #F1F5F9;
        --color-text-muted: #94A3B8;
        --color-border: #334155;
    }
}
*/
