/* ===================================================================
   PROCAM LR — Application stylesheet (v2)
   Palette: Procam Red #CC1E2E · Charcoal #111111 · Light Grey #F7F7F7
   Typography: Playfair Display (display) + DM Sans (body)
   Matches PRERNA PMS design system.
   ================================================================ */

:root {
    /* Brand — PRERNA-aligned */
    --procam-red:        #CC1E2E;
    --procam-red-dark:   #A8001F;
    --procam-red-light:  #FCE5E8;
    --procam-red-deep:   #7A0010;

    /* Neutrals */
    --charcoal:          #111111;
    --charcoal-soft:     #2A2A2A;
    --grey-900:          #1F2937;
    --grey-700:          #374151;
    --grey-500:          #6B7280;
    --grey-400:          #9CA3AF;
    --grey-300:          #D1D5DB;
    --grey-200:          #E5E7EB;
    --grey-100:          #F3F4F6;
    --grey-50:           #F7F7F7;
    --white:             #FFFFFF;

    /* Semantic */
    --bg:           #FAFAFA;
    --surface:      #FFFFFF;
    --surface-alt:  #F7F7F7;
    --border:       #E5E7EB;
    --border-strong:#C3CAD2;
    --text:         #111111;
    --text-muted:   #6B7280;
    --text-faint:   #9CA3AF;

    /* Status */
    --green:        #16A34A;
    --amber:        #D97706;
    --blue:         #2563EB;
    --purple:       #7C3AED;
    --slate:        #475569;

    /* Type */
    --font-display: 'Playfair Display', 'Georgia', 'Times New Roman', serif;
    --font-body:    'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono:    'JetBrains Mono', 'Courier New', monospace;

    /* Layout */
    --sidebar-width: 240px;
    --topbar-height: 60px;
    --radius:        6px;
    --radius-lg:     10px;
    --shadow-sm:     0 1px 2px rgba(0,0,0,0.04);
    --shadow:        0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg:     0 8px 24px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    margin: 0 0 0.5em 0;
    color: var(--charcoal);
    font-weight: 600;
    letter-spacing: -0.01em;
}
h1 { font-size: 1.85rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.18rem; }
h4 { font-size: 1.0rem; }
a { color: var(--procam-red); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--procam-red-dark); text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas: "sidebar topbar" "sidebar main";
    height: 100vh;
}

.topbar {
    grid-area: topbar;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    box-shadow: var(--shadow-sm);
}
.topbar-title {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--charcoal);
    font-size: 1.05rem;
}
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 0.75rem; }
.topbar-user .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--procam-red);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.9rem;
    font-family: var(--font-display);
}
.topbar-user-info { line-height: 1.2; }
.topbar-user-name { font-weight: 600; font-size: 0.9rem; color: var(--charcoal); }
.topbar-user-role { font-size: 0.75rem; color: var(--text-muted); }

.sidebar {
    grid-area: sidebar;
    background: var(--charcoal);
    color: white;
    padding: 0;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: var(--white);
    text-align: center;
}
.sidebar-brand img {
    max-width: 100%;
    max-height: 42px;
    display: block;
    margin: 0 auto;
}
.sidebar-tag {
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.4);
    text-align: center;
    padding: 0.7rem 1rem 0.3rem;
    text-transform: uppercase;
    font-weight: 500;
}
.sidebar-section {
    padding: 0.85rem 1.25rem 0.3rem;
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 1.5px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
}
.sidebar a {
    display: flex; align-items: center;
    padding: 0.6rem 1.25rem;
    color: rgba(255,255,255,0.82);
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
}
.sidebar a:hover {
    background: rgba(204,30,46,0.12);
    color: white;
    text-decoration: none;
}
.sidebar a.active {
    background: linear-gradient(90deg, rgba(204,30,46,0.22) 0%, rgba(204,30,46,0.05) 100%);
    border-left-color: var(--procam-red);
    color: white;
    font-weight: 500;
}
.sidebar a .icon {
    width: 18px;
    display: inline-block;
    text-align: center;
    margin-right: 0.6rem;
    opacity: 0.7;
}

.main {
    grid-area: main;
    overflow-y: auto;
    padding: 1.75rem 2rem;
    background: var(--bg);
}

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; padding-bottom: 1rem;
    border-bottom: 2px solid var(--procam-red);
}
.page-title { margin: 0; }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.35rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h2, .card-header h3, .card-title {
    margin: 0; font-size: 1rem;
    color: var(--charcoal);
    font-family: var(--font-display);
    font-weight: 600;
}
.card-body { padding: 1.25rem; }
.card-footer { padding: 0.75rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-alt); }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.kpi-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    position: relative; overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-tile::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--procam-red);
}
.kpi-tile.kpi-grey::before  { background: var(--charcoal); }
.kpi-tile.kpi-amber::before { background: var(--amber); }
.kpi-tile.kpi-green::before { background: var(--green); }
.kpi-tile.kpi-blue::before  { background: var(--blue); }
.kpi-tile.kpi-red::before   { background: var(--procam-red); }
.kpi-tile .label {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}
.kpi-tile .value {
    font-family: var(--font-display);
    font-size: 2.1rem;
    font-weight: 600;
    color: var(--charcoal);
    line-height: 1.1;
    margin-top: 0.3rem;
    letter-spacing: -0.02em;
}
.kpi-tile .delta { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem; }

.table-wrapper { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data th {
    background: var(--surface-alt);
    color: var(--charcoal);
    text-align: left;
    padding: 0.7rem 0.9rem;
    border-bottom: 2px solid var(--border-strong);
    font-weight: 600;
    white-space: nowrap;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
table.data td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tr:hover td { background: var(--grey-50); }
table.data .num { font-variant-numeric: tabular-nums; text-align: right; font-family: var(--font-mono); }
table.data .center { text-align: center; }

.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    letter-spacing: 0.2px;
}
.btn-primary { background: var(--procam-red); color: white; }
.btn-primary:hover { background: var(--procam-red-dark); color: white; text-decoration: none; box-shadow: 0 2px 6px rgba(204,30,46,0.25); }
.btn-danger { background: var(--procam-red-deep); color: white; }
.btn-danger:hover { background: #5d0008; color: white; text-decoration: none; }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { filter: brightness(0.92); color: white; text-decoration: none; }
.btn-secondary { background: var(--white); color: var(--charcoal); border-color: var(--grey-300); }
.btn-secondary:hover { background: var(--grey-50); color: var(--charcoal); text-decoration: none; border-color: var(--grey-400); }
.btn-sm { padding: 0.33rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--charcoal); margin-bottom: 0.4rem; }
.form-label .required { color: var(--procam-red); }
.form-control, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="datetime-local"], input[type="file"], select, textarea {
    width: 100%;
    padding: 0.55rem 0.8rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--white);
    border: 1px solid var(--grey-300);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--procam-red);
    box-shadow: 0 0 0 3px rgba(204,30,46,0.12);
}
textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 1rem; }
.form-help { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-error { color: var(--procam-red); font-size: 0.78rem; margin-top: 0.3rem; }

.badge {
    display: inline-block;
    padding: 0.22rem 0.65rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-gray   { background: var(--grey-200); color: var(--grey-700); }
.badge-amber  { background: #FEF3C7; color: var(--amber); }
.badge-blue   { background: #DBEAFE; color: var(--blue); }
.badge-purple { background: #EDE9FE; color: var(--purple); }
.badge-green  { background: #DCFCE7; color: var(--green); }
.badge-red    { background: var(--procam-red-light); color: var(--procam-red); }
.badge-slate  { background: #E2E8F0; color: var(--slate); }
.badge-navy   { background: var(--grey-100); color: var(--charcoal); }

.flash-list { margin-bottom: 1rem; }
.flash {
    padding: 0.85rem 1.1rem;
    margin-bottom: 0.6rem;
    border-radius: var(--radius);
    border-left: 4px solid;
    font-size: 0.9rem;
}
.flash.success { background: #F0FDF4; border-color: var(--green); color: #14532D; }
.flash.error   { background: #FEF2F2; border-color: var(--procam-red); color: #991B1B; }
.flash.warning { background: #FFFBEB; border-color: var(--amber); color: #78350F; }
.flash.info    { background: #EFF6FF; border-color: var(--blue); color: #1E3A8A; }

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--bg);
}
.login-brand {
    background: var(--charcoal);
    color: white;
    padding: 3.5rem;
    display: flex; flex-direction: column; justify-content: center;
    position: relative; overflow: hidden;
}
.login-brand::before {
    content: ''; position: absolute;
    right: -80px; top: -80px; width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(204,30,46,0.18) 0%, transparent 70%);
    border-radius: 50%;
}
.login-brand::after {
    content: ''; position: absolute;
    right: 20%; bottom: -100px; width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(204,30,46,0.08) 0%, transparent 70%);
    border-radius: 50%;
}
.login-brand-logo {
    background: white;
    padding: 1.5rem 1.75rem;
    border-radius: var(--radius-lg);
    display: inline-block;
    margin-bottom: 2rem;
    max-width: 320px;
    position: relative;
    z-index: 1;
}
.login-brand-logo img { width: 100%; height: auto; display: block; }
.login-brand-tag {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.05rem;
    color: rgba(255,255,255,0.75);
    margin-bottom: 2rem;
    position: relative; z-index: 1;
}
.login-brand-accent {
    height: 3px; width: 80px;
    background: var(--procam-red);
    margin-bottom: 2rem;
    position: relative; z-index: 1;
}
.login-brand-features { list-style: none; padding: 0; margin-top: auto; position: relative; z-index: 1; }
.login-brand-features li {
    color: rgba(255,255,255,0.85);
    margin: 0.55rem 0;
    font-size: 0.92rem;
    padding-left: 1.25rem;
    position: relative;
}
.login-brand-features li::before { content: '▸'; color: var(--procam-red); position: absolute; left: 0; }
.login-brand-footer { margin-top: 2rem; font-size: 0.78rem; color: rgba(255,255,255,0.5); position: relative; z-index: 1; }

.login-form-area {
    padding: 3rem;
    display: flex; flex-direction: column; justify-content: center;
    max-width: 480px; width: 100%; justify-self: center;
}
.login-card { background: var(--surface); padding: 2.5rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.login-card-logo { text-align: center; margin-bottom: 1.5rem; }
.login-card-logo img { max-height: 50px; }
.login-title {
    color: var(--charcoal); margin-bottom: 0.5rem;
    font-family: var(--font-display); font-size: 1.6rem;
}
.login-subtitle { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 1.75rem; }
.login-accent-line { width: 50px; height: 3px; background: var(--procam-red); margin: 0 0 1.5rem 0; }

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
    .sidebar { display: none; }
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { padding: 2rem; }
    .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
}

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-red   { color: var(--procam-red); }
.text-navy  { color: var(--charcoal); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap-1 { gap: 0.5rem; }
.flex-gap-2 { gap: 1rem; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
