/* Apple-Inspired Design System */

/* ===== CSS Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== Root Variables ===== */
:root {
    /* Colors - Milky Way Calendar Branding */
    --color-primary: #3d4070;
    --color-primary-hover: #2d3060;
    --color-primary-active: #1d2050;
    --color-accent: #f4b942;
    --color-accent-hover: #e6a830;
    --color-text-primary: #1a1a2e;
    --color-text-secondary: #6b6b7d;
    --color-background: #ffffff;
    --color-background-secondary: #f8f8fc;
    --color-border: #d0d0e0;
    --color-error: #d97b8e;
    --color-success: #5b7db8;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Spacing */
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-md: 16px;
    --font-size-lg: 20px;
    --font-size-xl: 28px;
    --font-size-2xl: 40px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Base Styles ===== */
body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    line-height: 1.6;
    color: var(--color-text-primary);
    background: var(--color-background-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Container ===== */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-sm);
    color: var(--color-text-primary);
}

.subtitle {
    font-size: var(--font-size-lg);
    font-weight: 400;
    color: var(--color-text-secondary);
}

/* ===== Cards ===== */
.card {
    background: var(--color-background);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-lg);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

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

/* ===== Form Styles ===== */
.form-group {
    margin-bottom: var(--space-lg);
    position: relative;
}

.form-group:last-of-type {
    margin-bottom: var(--space-xl);
}

label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xs);
    letter-spacing: 0.01em;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    height: 44px;
    padding: 0 var(--space-md);
    font-size: var(--font-size-md);
    font-family: var(--font-family);
    color: var(--color-text-primary);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

input.error {
    border-color: var(--color-error);
}

input.error:focus {
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1);
}

input::placeholder {
    color: var(--color-text-secondary);
    opacity: 0.6;
}

/* Helper Text & Error Messages */
.helper-text {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-top: var(--space-xs);
}

.error-message {
    display: none;
    font-size: var(--font-size-xs);
    color: var(--color-error);
    margin-top: var(--space-xs);
    font-weight: 500;
}

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

.char-counter {
    position: absolute;
    right: 0;
    bottom: -20px;
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

/* ===== Buttons ===== */
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    height: 50px;
    padding: 0 var(--space-xl);
    font-size: var(--font-size-md);
    font-weight: 600;
    font-family: var(--font-family);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    width: 100%;
    background: var(--color-primary);
    color: white;
}

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

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

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

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

.btn-secondary:hover {
    background: var(--color-border);
    transform: translateY(-1px);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Button Loading State */
.btn-primary.loading .btn-text {
    opacity: 0;
}

.btn-primary.loading .spinner {
    display: block;
}

.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    position: absolute;
}

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

/* ===== Result Card ===== */
.result-card {
    animation: slideUp var(--transition-slow);
}

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

.result-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.result-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.result-header p {
    font-size: var(--font-size-md);
    color: var(--color-text-secondary);
}

.preview {
    margin-bottom: var(--space-xl);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.preview img {
    width: 100%;
    height: auto;
    display: block;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.actions .btn-primary svg {
    width: 20px;
    height: 20px;
}

/* ===== Error Card ===== */
.error-card {
    text-align: center;
    animation: shake 0.4s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.error-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
}

.error-card h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--color-text-primary);
}

.error-card p {
    font-size: var(--font-size-md);
    color: var(--color-error);
    margin-bottom: var(--space-xl);
    line-height: 1.5;
}

/* ===== Footer ===== */
.footer {
    margin-top: auto;
    padding-top: var(--space-2xl);
    text-align: center;
}

.footer p {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.footer .admin-link {
    margin-top: var(--space-sm);
}

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

.footer .admin-link a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

/* ===== Responsive Design ===== */
@media (max-width: 640px) {
    .container {
        padding: var(--space-lg) var(--space-md);
    }

    .title {
        font-size: var(--font-size-xl);
    }

    .subtitle {
        font-size: var(--font-size-md);
    }

    .card {
        padding: var(--space-lg);
    }
}

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

/* ===== Focus Visible (Keyboard Navigation) ===== */
*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline-offset: 4px;
}
