/* ============================================================
   PHANTOM CRM — shared interface layer
   Keeps legacy pages visually aligned with the compact database UI.
============================================================ */

:root {
    --radius: 10px;
    --radius-sm: 7px;
    --surface: rgba(20, 20, 39, .82);
    --surface2: rgba(255, 255, 255, .065);
    --panel-gradient: linear-gradient(145deg, rgba(35, 35, 62, .92), rgba(20, 20, 39, .95));
    --panel-shadow: 0 12px 34px rgba(0, 0, 0, .2), 0 0 22px rgba(99, 102, 241, .045);
}

html { color-scheme: dark; }

body {
    font-size: 14px;
    background-image:
        radial-gradient(ellipse 72% 55% at 18% 0%, rgba(99, 102, 241, .15), transparent 62%),
        radial-gradient(ellipse 55% 46% at 88% 100%, rgba(139, 92, 246, .09), transparent 58%),
        linear-gradient(rgba(8, 8, 18, .88), rgba(8, 8, 18, .94));
    background-size: cover;
    background-attachment: fixed;
}

::selection { color: #fff; background: rgba(99, 102, 241, .55); }

/* ---- Application shell ---- */
.sidebar {
    width: 256px;
    box-shadow: 12px 0 36px rgba(0, 0, 0, .18);
}

.sidebar-header h3 { font-size: 1.05rem; }
.nav-links a { min-height: 38px; }
.nav-links a.active { background: linear-gradient(120deg, rgba(99,102,241,.22), rgba(139,92,246,.08)); }
.nav-header { font-size: .62rem; }
.user-panel { padding: 11px 13px; }

.main-content {
    min-width: 0;
    padding: 30px 34px 40px;
}

.main-content > :is(.admin-container, .dashboard-container, .container, .container-fluid, .editor-container) {
    width: 100%;
    max-width: 1500px;
    margin-left: auto;
    margin-right: auto;
}

.container-fluid { padding: 0 !important; }

/* ---- Page titles and headers ---- */
.page-header,
.header-row {
    gap: 18px;
    margin-bottom: 20px !important;
}

.page-header h1,
.dashboard-container > h1,
.dashboard-container > .header-row h1,
.admin-container > h1,
.container-fluid > h2,
.editor-container > h2 {
    margin-top: 0;
    font-size: 1.48rem;
    line-height: 1.25;
    font-weight: 800;
    background: linear-gradient(120deg, #fff 15%, #c4b5fd 62%, #67e8f9);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-header h1 i,
.dashboard-container h1 i { -webkit-text-fill-color: var(--accent-light); color: var(--accent-light); }

/* ---- Shared panels and cards ---- */
.glass-panel,
.card,
.editor-container {
    background: var(--panel-gradient);
    border: 1px solid rgba(148, 163, 255, .18);
    border-radius: 10px;
    box-shadow: var(--panel-shadow);
}

.glass-panel { padding: 18px; }
.glass-panel:hover,
.card:hover { border-color: rgba(129, 140, 248, .3); }

.glass-panel > :is(h2, h3):first-child,
.card-header h5 {
    color: #f1f5f9;
    font-size: .86rem;
    letter-spacing: .15px;
}

.card { padding: 0; overflow: hidden; }
.card-header {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0 16px !important;
    background: linear-gradient(90deg, rgba(99, 102, 241, .1), transparent 58%) !important;
    border-bottom-color: var(--border) !important;
}
.card-body { padding: 18px !important; }

/* ---- Forms ---- */
:is(input, select, textarea, button) { font-family: inherit; }

.form-input,
.form-control,
.styled-date-input,
.editor-container input:not([type='checkbox']):not([type='radio']):not([type='file']),
.editor-container select,
.editor-container textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    color: var(--text);
    background: rgba(255, 255, 255, .055);
    border: 1px solid var(--border);
    border-radius: 7px;
    outline: none;
    font-size: .8rem;
    transition: border-color .2s, box-shadow .2s, background .2s;
}

textarea.form-control,
.editor-container textarea { min-height: 92px; resize: vertical; }

:is(.form-input, .form-control, .styled-date-input):focus,
.editor-container :is(input, select, textarea):focus {
    border-color: var(--accent);
    background-color: rgba(99, 102, 241, .07);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .13);
}

:is(input, textarea)::placeholder { color: rgba(255, 255, 255, .25); }
select option { color: #e2e8f0; background: #141426; }
.form-group { margin-bottom: 15px; }
.form-group label { margin-bottom: 6px; color: var(--text-muted); font-size: .74rem; }

/* ---- Buttons and links ---- */
.btn-primary,
.btn-secondary,
.btn-upload,
.btn-login,
.btn-save-note,
.btn-save-script,
.btn-cancel-script {
    min-height: 38px;
    padding: 0 14px;
    border-radius: 7px;
    font-size: .76rem;
    letter-spacing: 0;
    box-shadow: none;
}

.btn-primary {
    border: 1px solid rgba(129, 140, 248, .42);
    background: linear-gradient(135deg, rgba(99, 102, 241, .92), rgba(124, 58, 237, .82));
    box-shadow: 0 5px 18px rgba(99, 102, 241, .2);
}

.btn-secondary { background: rgba(255, 255, 255, .04); }
.btn-primary:hover,
.btn-secondary:hover { transform: translateY(-1px); }

.btn-icon {
    min-width: 30px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(255, 255, 255, .04);
}

.btn-back,
.back-link { color: var(--text-muted) !important; font-size: .76rem; }
.btn-back:hover,
.back-link:hover { color: #fff !important; }

/* ---- Tables ---- */
.table-responsive,
.preview-table-container,
.history-table-container { overflow-x: auto; }

.data-table,
.history-table-container table,
.editor-container table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text);
}

.data-table th,
.data-table td,
.history-table-container th,
.history-table-container td {
    padding: 10px 11px !important;
    border-bottom: 1px solid rgba(255, 255, 255, .085) !important;
    font-size: .73rem;
    vertical-align: middle;
}

.data-table th,
.history-table-container th {
    color: rgba(226, 232, 240, .62) !important;
    background: rgba(255, 255, 255, .035);
    font-size: .64rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .42px;
    white-space: nowrap;
}

.data-table tbody tr:nth-child(even),
.history-table-container tbody tr:nth-child(even) { background: rgba(129, 140, 248, .035); }
.data-table tbody tr:hover,
.history-table-container tbody tr:hover { background: rgba(129, 140, 248, .1); }

.status-badge,
.badge,
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 650;
}

/* ---- Legacy pages ---- */
.stats-grid { gap: 14px !important; margin-bottom: 20px !important; }
.content-grid { gap: 16px !important; }
.teams-grid { gap: 14px !important; }
.mapping-grid { gap: 14px !important; }

.doc-grid { gap: 12px !important; }
.doc-btn {
    min-height: 150px;
    padding: 20px 14px !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, .035) !important;
    border-color: var(--border) !important;
}
.doc-btn:hover {
    transform: translateY(-3px) !important;
    background: rgba(99, 102, 241, .09) !important;
    border-color: rgba(129, 140, 248, .45) !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .22) !important;
}
.doc-btn i { color: var(--accent-light) !important; font-size: 2rem !important; }
.doc-title { font-size: .88rem !important; }
.doc-desc { color: var(--text-muted) !important; font-size: .7rem !important; }

.editor-container { padding: 20px; }
.editor-container .hint { color: var(--text-muted); }

/* Keep the shared shell professional and visually quiet. */
#petals-container { display: none; }

/* ---- Login ---- */
.login-container {
    max-width: 380px;
    padding: 38px 36px;
    border-radius: 12px;
    background: var(--panel-gradient);
    border: 1px solid rgba(129, 140, 248, .25);
    box-shadow: 0 22px 70px rgba(0, 0, 0, .55), 0 0 32px rgba(99, 102, 241, .12);
}
.login-container h2 { margin-bottom: 28px; font-size: 1.35rem; }
.login-container .login-stats {
    color: var(--text) !important;
    background: rgba(99, 102, 241, .09) !important;
    border: 1px solid rgba(99, 102, 241, .2);
    border-radius: 7px !important;
}
.login-container .login-stats p { color: var(--text-muted) !important; }
.btn-login { min-height: 42px; }

/* ---- Responsive shell ---- */
@media (max-width: 900px) {
    .sidebar { width: 210px; }
    .main-content { padding: 26px 22px 34px; }
}

@media (max-width: 700px) {
    .app-container { display: block; }
    .sidebar {
        width: 100%;
        height: auto;
        position: sticky;
        z-index: 1000;
        padding: 9px 12px;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .sidebar::after,
    .sidebar-header,
    .nav-header { display: none; }
    .nav-links {
        display: flex;
        gap: 5px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-links li { flex: 0 0 auto; margin: 0; }
    .nav-links a { min-height: 36px; padding: 7px 10px; }
    .nav-links a.active::before { display: none; }
    .nav-links a span { white-space: nowrap; }
    .user-info { display: none; }
    .main-content { padding: 20px 14px 30px; }
    .page-header,
    .header-row { align-items: flex-start !important; flex-direction: column; }
    .content-grid { grid-template-columns: 1fr !important; }
    .glass-panel { padding: 15px; }
    .form-row { flex-direction: column; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
