/* =============================================================================
   LernOS Leads — stylesheet

   Font is Lato throughout (house standard — no other family).
   No JavaScript alert() anywhere; confirmations use modals (see app.js).
   ============================================================================= */

:root {
    --primary:        #6366F1;
    --primary-dark:   #4338CA;
    --primary-light:  #EEF2FF;
    --accent:         #38BDF8;

    --text:           #0F172A;
    --text-muted:     #64748B;
    --text-faint:     #94A3B8;

    --bg:             #F8FAFC;
    --surface:        #FFFFFF;
    --border:         #E2E8F0;
    --border-strong:  #CBD5E1;

    --success:        #16A34A;
    --success-bg:     #F0FDF4;
    --warning:        #D97706;
    --warning-bg:     #FFFBEB;
    --danger:         #DC2626;
    --danger-bg:      #FEF2F2;
    --info-bg:        #EFF6FF;

    --radius:         10px;
    --radius-sm:      7px;
    --shadow:         0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
    --shadow-lg:      0 10px 25px -5px rgba(15, 23, 42, .12), 0 8px 10px -6px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .25rem; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

/* ---------------------------------------------------------------- layout -- */

.page-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: #111827;
    color: #C7D2FE;
    display: flex;
    flex-direction: column;
    padding: 1.1rem 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.1rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: .9rem;
}

.sidebar-brand-text {
    font-weight: 900;
    font-size: 1.02rem;
    color: #fff;
    letter-spacing: -.02em;
}
.sidebar-brand-text span { color: var(--accent); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .6rem; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .7rem;
    border-radius: var(--radius-sm);
    color: #C7D2FE;
    font-weight: 500;
    font-size: .91rem;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }

.sidebar-foot {
    margin-top: auto;
    padding: .9rem 1.1rem 0;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .82rem;
}
.sidebar-foot .who { color: #fff; font-weight: 700; }
.sidebar-foot .role { color: #94A3B8; text-transform: capitalize; }

.main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 1.6rem 2rem 3rem;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.3rem;
    flex-wrap: wrap;
}
.topbar .sub { color: var(--text-muted); font-size: .88rem; margin: 0; }
.topbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------------------------------------------------------------- cards --- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .8rem;
    margin-bottom: 1.3rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    box-shadow: var(--shadow);
}
.stat .label {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
    font-weight: 700;
}
.stat .value { font-size: 1.65rem; font-weight: 900; line-height: 1.2; margin-top: .15rem; }
.stat .value.warn { color: var(--warning); }
.stat .value.good { color: var(--success); }
.stat .value.bad  { color: var(--danger); }

/* --------------------------------------------------------------- buttons -- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem .9rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: .89rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: #F1F5F9; color: var(--text); }

.btn-danger { background: #fff; color: var(--danger); border-color: #FECACA; }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }

.btn-sm { padding: .34rem .65rem; font-size: .81rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ----------------------------------------------------------------- forms -- */

.field { margin-bottom: .95rem; }
.field label {
    display: block;
    font-size: .82rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: .28rem;
}
.field .hint { font-size: .77rem; color: var(--text-muted); margin-top: .25rem; }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=date], input[type=search], select, textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .93rem;
    color: var(--text);
    background: #fff;
    transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { resize: vertical; min-height: 90px; }

.field-row { display: flex; gap: .8rem; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 180px; margin-bottom: .95rem; }

.phone-group { display: flex; gap: .4rem; }
.phone-group .cc { flex: 0 0 82px; }

.input-warn { border-color: var(--warning) !important; background: var(--warning-bg); }

/* ---------------------------------------------------------------- alerts -- */

.alert {
    border-radius: var(--radius-sm);
    padding: .7rem .9rem;
    font-size: .89rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); border-color: #BBF7D0; color: #166534; }
.alert-error   { background: var(--danger-bg);  border-color: #FECACA; color: #991B1B; }
.alert-info    { background: var(--info-bg);    border-color: #BFDBFE; color: #1E40AF; }
.alert-warning { background: var(--warning-bg); border-color: #FDE68A; color: #92400E; }

/* ---------------------------------------------------------------- tables -- */

.table-wrap { overflow-x: auto; border-radius: var(--radius); }

table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: .89rem;
}
table.data th {
    text-align: left;
    padding: .62rem .8rem;
    background: #F8FAFC;
    border-bottom: 1px solid var(--border);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-faint);
    font-weight: 700;
    white-space: nowrap;
}
table.data td {
    padding: .68rem .8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #FAFBFF; }
table.data .institute { font-weight: 700; }
table.data .muted { color: var(--text-muted); }
table.data .nowrap { white-space: nowrap; }

.empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty h2 { color: var(--text); margin-bottom: .3rem; }

/* Full-page message, used by 404.php. */
.empty-state { text-align: center; color: var(--text-muted); max-width: 380px; }
.empty-state h1 { color: var(--text); }
.empty-state .empty-code {
    font-size: 3.4rem;
    font-weight: 900;
    line-height: 1;
    color: var(--primary);
    margin-bottom: .3rem;
}
.empty-state .btn { margin-top: 1rem; }

/* Read-only definition list, used on a lead another user owns. */
dl.readonly { margin: 0; display: grid; grid-template-columns: 130px 1fr; gap: .45rem .8rem; }
dl.readonly dt { color: var(--text-faint); font-size: .79rem; font-weight: 700;
                 text-transform: uppercase; letter-spacing: .04em; padding-top: .15rem; }
dl.readonly dd { margin: 0; font-size: .9rem; }

/* ---------------------------------------------------------------- badges -- */

.badge {
    display: inline-block;
    padding: .17rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
    line-height: 1.5;
}
.badge-new            { background: #E0E7FF; color: #3730A3; }
.badge-contacted      { background: #E0F2FE; color: #075985; }
.badge-interested     { background: #FEF3C7; color: #92400E; }
.badge-demo_scheduled { background: #EDE9FE; color: #5B21B6; }
.badge-negotiating    { background: #FFE4E6; color: #9F1239; }
.badge-won            { background: #DCFCE7; color: #166534; }
.badge-lost           { background: #F1F5F9; color: #475569; }

.chip {
    display: inline-block;
    padding: .12rem .45rem;
    border-radius: 5px;
    font-size: .71rem;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary-dark);
}
.chip-website { background: #E0F2FE; color: #075985; }

.due-overdue { color: var(--danger); font-weight: 700; }
.due-today   { color: var(--warning); font-weight: 700; }
.due-soon    { color: var(--text-muted); }

/* --------------------------------------------------------------- toolbar -- */

.toolbar {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
}
.toolbar .grow { flex: 1 1 auto; min-width: 160px; }
.toolbar input[type=search] { max-width: 300px; }

.filter-tabs { display: flex; gap: .3rem; flex-wrap: wrap; }
.filter-tabs a {
    padding: .34rem .7rem;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-muted);
    background: #fff;
    border: 1px solid var(--border);
}
.filter-tabs a:hover { background: #F1F5F9; text-decoration: none; }
.filter-tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ----------------------------------------------------------- login page --- */

.page-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: linear-gradient(150deg, #EEF2FF 0%, #F8FAFC 45%, #E0F2FE 100%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 1.8rem;
}

.login-brand {
    text-align: center;
    margin-bottom: 1.4rem;
}
.login-brand .mark {
    font-size: 1.42rem;
    font-weight: 900;
    letter-spacing: -.03em;
}
.login-brand .mark span { color: var(--primary); }
.login-brand p { color: var(--text-muted); font-size: .85rem; margin: .15rem 0 0; }

/* -------------------------------------------------------------- activity -- */

.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
    display: flex;
    gap: .7rem;
    padding: .62rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .87rem;
}
.feed li:last-child { border-bottom: none; }
.feed .when { color: var(--text-faint); font-size: .79rem; white-space: nowrap; margin-left: auto; }

.avatar {
    flex: 0 0 30px;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 900;
}

/* ----------------------------------------------------------------- modal -- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    z-index: 100;
}
.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    padding: 1.4rem;
}
.modal h3 { margin-bottom: .4rem; }
.modal p { color: var(--text-muted); font-size: .9rem; margin: 0 0 1.2rem; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; }

[hidden] { display: none !important; }

/* ------------------------------------------------------------ responsive -- */

@media (max-width: 820px) {
    .page-shell { flex-direction: column; }

    .sidebar {
        width: 100%;
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        padding: .6rem .8rem;
        overflow-x: auto;
    }
    .sidebar-brand { border: none; margin: 0 1rem 0 0; padding: 0; }
    .sidebar-nav { flex-direction: row; padding: 0; gap: .3rem; }
    .sidebar-nav a { white-space: nowrap; padding: .4rem .6rem; font-size: .85rem; }
    .sidebar-foot { margin: 0 0 0 auto; border: none; padding: 0 0 0 .8rem; display: none; }

    .main { padding: 1.1rem 1rem 2.5rem; }
    .topbar { flex-direction: column; align-items: stretch; }
    .toolbar input[type=search] { max-width: none; }
    .stat .value { font-size: 1.4rem; }
}

@media print {
    .sidebar, .topbar-actions, .toolbar { display: none; }
    .main { padding: 0; }
}
