/* File: webroot/css/basic.css */

/*
 * ====================================================================
 *  CORE DESIGN TOKENS (CSS VARIABLES) - 2026 ARCHITECTURE
 * ====================================================================
 *  This file defines the global styling for the application.
 *  It includes a default light theme and an automatic dark theme
 *  based on the user's operating system preference.
 */

:root {
    /* -- Font & Spacing -- */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius: 0.75rem; /* 12px */
    --spacing-unit: 0.25rem;  /* 4px */

    /* -- Light Theme Color Palette (Default) -- */
    --bg-color: #f8fafc;        /* Slate 50 */
    --card-bg: #ffffff;         /* White */
    --text-main: #0f172a;       /* Slate 900 */
    --text-muted: #475569;      /* Slate 600 */
    --primary: #3b82f6;         /* Blue 500 */
    --primary-hover: #2563eb;    /* Blue 600 */
    --primary-text: #ffffff;    /* White text on primary buttons */
    --border: #e2e8f0;          /* Slate 200 */
    --success: #16a34a;         /* Green 600 */
    --danger: #dc2626;          /* Red 600 */
    --focus-ring: rgba(59, 130, 246, 0.4);
}

@media (prefers-color-scheme: dark) {
    :root {
        /* -- Dark Theme Color Palette -- */
        --bg-color: #0f172a;        /* Slate 900 */
        --card-bg: #1e293b;         /* Slate 800 */
        --text-main: #e2e8f0;       /* Slate 200 */
        --text-muted: #94a3b8;      /* Slate 400 */
        --primary: #60a5fa;         /* Blue 400 */
        --primary-hover: #3b82f6;    /* Blue 500 */
        --primary-text: #0f172a;    /* Dark text on primary buttons */
        --border: #334155;          /* Slate 700 */
        --success: #22c55e;         /* Green 500 */
        --danger: #f87171;          /* Red 400 */
        --focus-ring: rgba(96, 165, 250, 0.4);
    }
}


/*
 * ====================================================================
 *  GLOBAL STYLES & RESETS
 * ====================================================================
 */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    padding: calc(var(--spacing-unit) * 8) calc(var(--spacing-unit) * 4); /* 32px 16px */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s, color 0.2s;
}

h1, h2, h3, h4, h5, h6 {
    text-wrap: balance;
}

p {
    max-width: 65ch; /* Improves readability */
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: opacity 0.2s;
}
a:hover {
    text-decoration: underline;
    opacity: 0.8;
}


/*
 * ====================================================================
 *  LAYOUT & SHARED COMPONENTS
 * ====================================================================
 */

.container {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.form-group {
    margin-bottom: calc(var(--spacing-unit) * 5); /* 20px */

    & label {
        display: block;
        margin-bottom: calc(var(--spacing-unit) * 2); /* 8px */
        font-weight: 500;
        font-size: 0.875rem; /* 14px */
        color: var(--text-muted);
    }

    & input,
    & select {
        display: block;
        width: 100%;
        padding: calc(var(--spacing-unit) * 3) calc(var(--spacing-unit) * 4); /* 12px 16px */
        border: 1px solid var(--border);
        border-radius: var(--border-radius);
        font-size: 1rem;
        background-color: var(--bg-color); /* Use bg-color for inputs for contrast */
        color: var(--text-main);
        transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;

        &:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--focus-ring);
        }
    }
}

.btn-primary {
    display: inline-block;
    width: 100%;
    padding: calc(var(--spacing-unit) * 4) calc(var(--spacing-unit) * 6); /* 16px 24px */
    background-color: var(--primary);
    color: var(--primary-text);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.125rem; /* 18px */
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s;

    &:hover {
        background-color: var(--primary-hover);
    }
    
    &:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }
}


/*
 * ====================================================================
 *  TOAST NOTIFICATIONS (GLOBAL COMPONENT)
 * ====================================================================
 */

.toast-container {
    position: fixed;
    bottom: calc(var(--spacing-unit) * 8); /* 32px */
    right: calc(var(--spacing-unit) * 8); /* 32px */
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 2); /* 8px */
    z-index: 9999;
}

.toast {
    padding: calc(var(--spacing-unit) * 4) calc(var(--spacing-unit) * 6); /* 16px 24px */
    border-radius: var(--border-radius);
    color: white;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    animation: toastSlideIn 0.3s cubic-bezier(0.21, 1.02, 0.73, 1) forwards, 
               toastFadeOut 0.3s ease-in forwards 4.7s;
    
    &.success { background-color: var(--success); }
    &.error { background-color: var(--danger); }
}

@keyframes toastSlideIn {
    from { transform: translateX(calc(100% + var(--spacing-unit) * 8)); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastFadeOut {
    from { opacity: 1; }
    to { opacity: 0; transform: scale(0.95); }
}