/* style.css */
/* Data Cleaning Pattern Checker */

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg-gradient);
    transition: background 0.3s ease, color 0.3s ease;
}

button, input, textarea, select { font: inherit; }
button { border: 0; }
a { color: inherit; text-decoration: none; }

.app-shell {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 24px;
}

.hero {
    position: relative;
    overflow: hidden;
    border-radius: 28px;
    padding: 32px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.12);
}

.hero::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    right: -120px;
    bottom: -160px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    pointer-events: none;
}

.topbar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 40px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    color: var(--primary);
    background: white;
    font-weight: 900;
    letter-spacing: -0.03em;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.18);
}

.brand-title { font-size: 1.35rem; font-weight: 850; }
.brand-subtitle { font-size: 0.92rem; opacity: 0.85; }

.top-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.theme-selector {
    width: auto;
    min-width: 190px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 999px;
    padding: 10px 14px;
    outline: none;
    cursor: pointer;
}
.theme-selector option { color: #000; }

.guide-link, .ghost-button, .secondary-button, .primary-button, .download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 750;
    transition: all 0.18s ease;
}

.guide-link {
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.32);
    background: rgba(255, 255, 255, 0.15);
}

.guide-link:hover, .ghost-button:hover, .secondary-button:hover, .primary-button:hover, .download-button:hover {
    transform: translateY(-2px);
}

.hero-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 24px;
    align-items: end;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent-2);
    font-size: 0.8rem;
    font-weight: 850;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.hero h1 {
    max-width: 850px;
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.8rem);
    line-height: 1;
    letter-spacing: -0.05em;
}

.hero-text {
    margin: 20px 0 0;
    max-width: 860px;
    font-size: 1.15rem;
    line-height: 1.6;
    opacity: 0.92;
}

.hero-tags { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero-tags span {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.24);
    font-size: 0.9rem;
    font-weight: 700;
}

.profile-card {
    padding: 24px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
}
.profile-label { color: var(--accent-2); font-size: 0.75rem; font-weight: 850; text-transform: uppercase; }
.profile-name { margin-top: 10px; font-size: 1.35rem; font-weight: 850; }
.profile-meta { margin-top: 6px; opacity: 0.78; }

.main-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 24px;
    margin-top: 24px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--card);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.05);
    padding: 28px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.panel-header h2 { margin: 0; font-size: 1.6rem; color: var(--primary); }
.panel-header p { margin: 6px 0 0; color: var(--muted); line-height: 1.5; }

.upload-box {
    position: relative;
    display: grid;
    place-items: center;
    text-align: center;
    min-height: 230px;
    padding: 28px;
    border: 2px dashed var(--line);
    border-radius: 22px;
    background: rgba(0,0,0,0.02);
    transition: all 0.2s ease;
}
.upload-box.is-dragover {
    border-color: var(--primary);
    background: rgba(0,0,0,0.04);
    transform: scale(1.01);
}
.upload-box input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.upload-icon { font-size: 3.2rem; margin-bottom: 8px; }
.upload-box h3 { margin: 0 0 8px; color: var(--primary); }
.upload-box p { max-width: 520px; margin: 0 auto 14px; color: var(--muted); line-height: 1.55; }
.file-name {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 12px;
    border-radius: 999px;
    color: var(--primary);
    background: rgba(0,0,0,0.04);
    font-size: 0.9rem;
    font-weight: 750;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 22px;
}
.form-group { min-width: 0; }
label { display: block; margin-bottom: 8px; color: var(--ink); font-weight: 750; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--ink);
    background: transparent;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}

.note-box {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    color: var(--muted);
    background: rgba(0,0,0,0.025);
    line-height: 1.55;
}

.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.primary-button { color: white; background: var(--primary); min-width: 170px; }
.secondary-button { color: var(--primary); background: transparent; border: 1px solid var(--primary); }
.ghost-button { color: var(--primary); background: transparent; border: 1px solid var(--line); }
.download-button { color: white; background: var(--primary); white-space: nowrap; }
button:disabled { cursor: not-allowed; opacity: 0.6; transform: none !important; }

.button-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}
.primary-button.is-loading .button-spinner { display: inline-block; }
.large-spinner {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 4px solid var(--line);
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-box {
    margin-bottom: 20px;
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid var(--line);
    color: var(--primary);
    font-weight: 600;
    background: rgba(0,0,0,0.02);
}

.result {
    min-height: 550px;
    max-height: 75vh;
    overflow-y: auto;
    padding: 24px;
    border-radius: 16px;
    background: transparent;
    border: 1px solid var(--line);
}
.result h2 {
    margin: 24px 0 12px;
    color: var(--primary);
    font-size: 1.35rem;
    border-bottom: 2px solid var(--line);
    padding-bottom: 8px;
}
.result p, .result li { line-height: 1.7; font-size: 1rem; }
.result ul { padding-left: 1.2rem; }

.download-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px;
    border-radius: 18px;
    background: rgba(0,0,0,0.035);
    border: 1px solid var(--line);
}
.download-card h3 { margin: 0 0 6px; color: var(--primary); }
.download-card p { margin: 0; color: var(--muted); }

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0;
}
.metrics-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card {
    padding: 16px;
    border-radius: 16px;
    background: rgba(0,0,0,0.025);
    border: 1px solid var(--line);
}
.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.metric-card strong {
    display: block;
    margin-top: 8px;
    color: var(--primary);
    font-size: 1.7rem;
}
.metric-warning strong { color: #c62828; }
.metric-ok strong { color: #1b5e20; }

.settings-list { margin: 0; }
.table-scroll { width: 100%; overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.92rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--line);
}
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--primary); color: white; font-weight: 700; white-space: nowrap; }
tr:nth-child(even) td { background: rgba(0,0,0,0.02); }

.badge {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}
.badge-ok { background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; }
.badge-outlier, .badge-constant { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.badge-low-sd { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }
.badge-trend { background: #e3f2fd; color: #0d47a1; border: 1px solid #bbdefb; }
.badge-warning { background: #f3e5f5; color: #4a148c; border: 1px solid #e1bee7; }

.empty-state, .loading-state, .error-state {
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
    height: 100%;
}
.empty-icon { font-size: 3.5rem; margin-bottom: 16px; }
.error-state h3 { color: #c62828; }

@media (max-width: 1100px) {
    .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .app-shell { padding: 14px; }
    .hero { padding: 24px; border-radius: 22px; }
    .topbar { align-items: flex-start; flex-direction: column; margin-bottom: 28px; }
    .hero-grid, .main-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 2.25rem; }
    .settings-grid { grid-template-columns: 1fr; }
    .download-card { align-items: stretch; flex-direction: column; }
    .download-button { width: 100%; }
    .result { max-height: none; min-height: 420px; }
}

@media (max-width: 560px) {
    .panel { padding: 18px; border-radius: 18px; }
    .brand-mark { width: 46px; height: 46px; }
    .brand-title { font-size: 1.05rem; }
    .theme-selector { width: 100%; }
    .guide-link { width: 100%; }
    .top-actions { width: 100%; }
    .metrics-grid, .metrics-grid.compact { grid-template-columns: 1fr; }
}
