/* Caisson Dashboard — Brand Stylesheet
   Colors: Primary Navy #011536, Dark Navy #021D49, White #FFFFFF
   Fonts: Arial Narrow (data/tables), system sans-serif (UI)
*/

:root {
    --navy: #011536;
    --navy-dark: #021D49;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;

    /* Status colors */
    --green: #059669;
    --green-light: #D1FAE5;
    --red: #DC2626;
    --red-light: #FEE2E2;
    --amber: #D97706;
    --amber-light: #FEF3C7;
    --blue: #2563EB;
    --blue-light: #DBEAFE;

    /* Layout */
    --sidebar-width: 240px;
    --header-height: 56px;
    --chat-width: 25%;
    --border-radius: 6px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
    font-family: 'Segoe UI', Calibri, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Layout Shell ── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--navy);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-logo .subtitle {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav a.active {
    color: var(--white);
    background: rgba(255, 255, 255, 0.12);
    border-left-color: var(--white);
    font-weight: 600;
}

.sidebar-nav .nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    flex-shrink: 0;
}

.sidebar-nav a.active .nav-icon,
.sidebar-nav a:hover .nav-icon {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

/* Main content area */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

/* Page header */
.page-header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--navy);
}

.page-header .header-meta {
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* Page toolbar */
.page-toolbar {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: 8px 28px;
    display: flex;
    align-items: center;
    gap: 6px;
    position: sticky;
    top: var(--header-height);
    z-index: 49;
}

.toolbar-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 6px;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--gray-300);
    margin: 0 4px;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-700);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.toolbar-btn:hover {
    border-color: var(--navy);
    color: var(--navy);
    box-shadow: var(--shadow-sm);
}

.toolbar-btn:disabled, .toolbar-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.toolbar-btn svg {
    flex-shrink: 0;
}

/* Page body */
.page-body {
    padding: 24px 28px;
}

/* ── Department Page Layout ── */

.dept-layout {
    display: flex;
    gap: 24px;
    min-height: calc(100vh - var(--header-height) - 48px);
}

.dept-main {
    flex: 1;
    min-width: 0;
}

.dept-chat {
    width: var(--chat-width);
    min-width: 280px;
    max-width: 400px;
    flex-shrink: 0;
}

/* ── Cards ── */

.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--navy);
}

.card-body {
    padding: 18px;
}

/* ── Homepage Department Cards ── */

.dept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    max-width: 1100px;
}

.dept-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dept-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
    transform: translateY(-2px);
}

.dept-card-accent {
    height: 4px;
}

.dept-card-body {
    padding: 20px;
    flex: 1;
}

.dept-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    font-size: 1.2rem;
}

.dept-card-body h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 4px;
}

.dept-card-body .owner {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 10px;
}

.dept-card-body p {
    font-size: 0.85rem;
    color: var(--gray-600);
    line-height: 1.5;
}

/* ── KPI / Status Cards ── */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}

.kpi-card .kpi-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.kpi-card .kpi-value {
    font-family: 'Arial Narrow', Arial, sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--navy);
}

.kpi-card .kpi-meta {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 4px;
}

/* ── Status Badges ── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-green {
    background: var(--green-light);
    color: var(--green);
}

.badge-red {
    background: var(--red-light);
    color: var(--red);
}

.badge-amber {
    background: var(--amber-light);
    color: var(--amber);
}

.badge-blue {
    background: var(--blue-light);
    color: var(--blue);
}

/* ── Status dot (small indicator) ── */

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.green { background: var(--green); }
.status-dot.red { background: var(--red); }
.status-dot.amber { background: var(--amber); }

/* ── Tables ── */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Arial Narrow', Arial, sans-serif;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    padding: 8px 12px;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.data-table tr:hover td {
    background: var(--gray-50);
}

.data-table .number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Section Headers ── */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy);
}

/* ── Chat Sidebar ── */

.chat-container {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height) - 48px);
    position: sticky;
    top: calc(var(--header-height) + 24px);
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--navy);
    display: flex;
    align-items: center;
    gap: 8px;
}

.new-chat-btn {
    margin-left: auto;
    padding: 4px;
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s;
}

.new-chat-btn:hover {
    color: var(--navy);
    border-color: var(--navy);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.chat-messages .empty-state {
    text-align: center;
    color: var(--gray-400);
    font-size: 0.85rem;
    padding: 40px 20px;
}

.chat-input-area {
    padding: 12px;
    border-top: 1px solid var(--gray-100);
}

.chat-input-area textarea {
    width: 100%;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    font-size: 0.85rem;
    font-family: inherit;
    resize: none;
    rows: 3;
    outline: none;
    transition: border-color 0.15s;
}

.chat-input-area textarea:focus {
    border-color: var(--navy);
}

.chat-input-area button {
    margin-top: 8px;
    width: 100%;
    padding: 8px;
    background: var(--navy);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-input-area button:hover {
    background: var(--navy-dark);
}

/* ── Tool Buttons ── */

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--navy);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.tool-btn:hover {
    border-color: var(--navy);
    box-shadow: var(--shadow-sm);
}

.tool-btn .tool-icon {
    font-size: 1.1rem;
}

/* ── Chat Messages ── */

.chat-msg {
    margin-bottom: 12px;
}

.chat-msg-user .chat-msg-content {
    background: var(--navy);
    color: var(--white);
    padding: 8px 12px;
    border-radius: 12px 12px 4px 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-left: 20%;
}

.chat-msg-assistant .chat-msg-content {
    background: var(--gray-100);
    color: var(--gray-800);
    padding: 8px 12px;
    border-radius: 12px 12px 12px 4px;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-right: 10%;
}

.typing-indicator {
    display: inline-block;
    color: var(--gray-400);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ── Disabled state ── */

button:disabled, .tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:disabled:hover, .tool-btn:disabled:hover {
    border-color: var(--gray-200);
    box-shadow: none;
}

/* ── Forms ── */

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.text-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    background: var(--white);
}

.text-input:focus {
    border-color: var(--navy);
}

.file-input {
    font-size: 0.85rem;
    font-family: inherit;
    padding: 6px 0;
}

/* ── Drop Zone ── */

.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--border-radius);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
}

.drop-zone:hover {
    border-color: var(--navy);
    background: var(--gray-50);
}

.drop-zone.drop-zone--over {
    border-color: var(--navy);
    background: var(--blue-light);
}

.drop-zone.drop-zone--has-file {
    border-color: var(--green);
    background: var(--green-light);
}

.drop-zone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.drop-zone-prompt {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin: 0;
    pointer-events: none;
}

.drop-zone-browse {
    color: var(--navy);
    font-weight: 600;
    text-decoration: underline;
}

.drop-zone-filename {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
    display: none;
    pointer-events: none;
}

.drop-zone--has-file .drop-zone-prompt { display: none; }
.drop-zone--has-file .drop-zone-filename { display: block; }

.btn-primary {
    padding: 10px 24px;
    background: var(--navy);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--navy-dark);
}

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: block;
}

.htmx-request .btn-primary {
    opacity: 0.6;
    pointer-events: none;
}

/* ── Utility ── */

.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-24 { margin-top: 24px; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.8rem; }
.text-mono { font-family: 'Arial Narrow', Arial, sans-serif; font-variant-numeric: tabular-nums; }
