/* * common.css
 * Shared styles for variables, typography, layout skeleton, header, footer,
 * utilities, chips, and base modal functionality.
 */

*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg-color: #F5F5F7;
    --card-bg: #FFFFFF;
    --primary: #0071E3;
    --primary-hover: #0077ED;
    --text-main: #1D1D1F;
    --text-secondary: #86868B;
    --border: #D2D2D7;
    --success: #34C759;
    --danger: #FF3B30;
    --radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --header-height: 60px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    width: 100%;
    overscroll-behavior-y: none;
}

/* --- Header --- */
.app-header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--header-height) + env(safe-area-inset-top));
}

.header-brand {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.05em;
    color: #111827;
    text-decoration: none;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-nav {
    display: flex;
    align-items: center;
}

.header-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    margin-right: 15px;
    font-size: 0.9rem;
}

.stage-badge {
    padding: 4px 10px;
    background: #1D1D1F;
    color: white;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stage-badge.warning { background-color: #FF9500; }

/* --- Maintenance Overlay --- */
.maintenance-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 99999; background-color: #fff; overflow-y: auto;
}
.maintenance-container {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%; text-align: center;
    padding: 20px; font-family: sans-serif;
}
.maintenance-container h1 { color: #1D1D1F; }
.maintenance-container p { color: #86868B; }
.maintenance-btn {
    padding: 12px 24px; margin-top: 20px; background: #0071E3;
    color: white; border: none; border-radius: 20px; font-weight: 600; cursor: pointer;
}

/* --- Auth Timeout UI --- */
.auth-timeout-container { text-align: center; padding: 20px; font-family: sans-serif; }
.auth-timeout-icon { font-size: 2rem; margin-bottom: 10px; }
.auth-timeout-text { margin-bottom: 20px; color: #666; }
.auth-timeout-btn {
    padding: 10px 20px; background: #0071E3; color: white;
    border: none; border-radius: 20px; cursor: pointer;
}

/* --- Chips (Shared) --- */
.chip-container { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 6px 14px; border-radius: 20px; background: #FFFFFF;
    color: #1D1D1F; font-size: 0.85rem; border: 1px solid #D2D2D7;
    font-weight: 500; display: inline-flex; align-items: center;
    transition: all 0.2s ease;
}
.chip-img {
    width: 18px; height: 18px; border-radius: 3px; margin-right: 6px;
    object-fit: contain; background: #f5f5f7; flex-shrink: 0;
}
.chip-remove { margin-left: 6px; opacity: 0.6; cursor: pointer; font-weight: bold; }
.chip-remove:hover { opacity: 1; }
.chip.selectable { cursor: pointer; }
.chip.selectable:hover { background-color: #f5f5f7; }
.chip.selected { background: #0071E3; color: white; border-color: #0071E3; }
.chip.selected .chip-remove { color: white; opacity: 0.8; }

/* --- Base Modal --- */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4); z-index: 2000;
    opacity: 0; visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    display: flex; flex-direction: column;
}
.modal:not(.hidden) { opacity: 1; visibility: visible; }
.close-btn {
    font-size: 1.8rem; cursor: pointer; color: #C7C7CC;
    line-height: 1; transition: color 0.2s;
}

/* --- Footer --- */
footer {
    text-align: center; padding: 40px 20px; color: var(--text-secondary);
    font-size: 0.8rem; border-top: 1px solid var(--border);
    margin-top: auto; position: relative; overflow: hidden;
    width: 100%; padding-bottom: env(safe-area-inset-bottom);
}
footer { padding: 80px 20px; }
.footer-bg-text {
    display: block;
    width: 100%;
    color: rgba(0,0,0,0.25);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.8;
    text-transform: uppercase;
    letter-spacing: 1px;
    max-width: 1000px;          /* Optional: Prevents lines from getting too wide on desktop */
    margin: 0 auto;
}
.footer-content {
    background: rgba(245, 245, 247, 0.8); display: inline-block;
    padding: 10px 20px; border-radius: 8px; backdrop-filter: blur(2px);
}
.footer-content a { color: var(--text-secondary); text-decoration: none; font-weight: 600; }
.footer-content a:hover { text-decoration: underline; }

/* --- Toast --- */
#toast-container {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 9999; display: flex; flex-direction: column; gap: 10px;
    width: 90%; max-width: 400px; top: calc(20px + env(safe-area-inset-top));
    pointer-events: none;
}
.toast {
    background: #fff; padding: 12px 20px; border-radius: 50px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1); font-size: 0.9rem;
    display: flex; align-items: center; justify-content: center;
    gap: 10px; pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.toast.success { background: #f2faf5; border: 1px solid #d1e7dd; color: #105c28; }
.toast.error { background: #FFF5F5; border: 1px solid #FED7D7; color: #C53030; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* --- Toggle Switch --- */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #34C759; }
input:checked + .slider:before { transform: translateX(18px); }

/* --- Typography Defaults --- */
h1 { color: var(--text-main); font-weight: 700; letter-spacing: -0.5px; margin-bottom: 0.5rem; }
h2 { color: var(--text-main); font-weight: 600; letter-spacing: -0.5px; margin-bottom: 0.5rem; }
h3 { font-weight: 600; color: var(--text-main); margin: 0 0 10px 0; }
p { color: var(--text-secondary); line-height: 1.5; font-size: 0.95rem; }

/* --- UTILITIES & HELPERS --- */
.hidden { display: none !important; }
.error { color: var(--danger); margin-top: 10px; font-size: 0.9rem; font-weight: 500; }
.text-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.contents { display: contents; }
.relative { position: relative; }
.inline-block { display: inline-block; }
.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.flex-1 { flex: 1; }
.mx-auto { margin-left: auto; margin-right: auto; }
.w-full { width: 100%; }
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-5 { margin-top: 5px; }
.mt-10 { margin-top: 10px; }
.mr-10 { margin-right: 10px; }
.ml-10 { margin-left: 10px; }
.mb-5 { margin-bottom: 5px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }
.mb-25 { margin-bottom: 25px; }
.mt-20 { margin-top: 20px; }
.mt-25 { margin-top: 25px; }
.mt-40 { margin-top: 40px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 600; }
.font-sm { font-size: 0.9rem; }
.cursor-pointer { cursor: pointer; }