/* Fish Farming Management System - Clean Light Theme Design System */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Primary Colors: Clean, crisp, high-contrast daylight theme */
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-subtle: #f1f5f9;
    --bg-modal-backdrop: rgba(15, 23, 42, 0.45);
    
    /* Text shades */
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    /* Brand & Accent Colors */
    --brand-primary: #0284c7;     /* Sky / Ocean 600 */
    --brand-primary-hover: #0369a1;
    --brand-primary-subtle: #e0f2fe;
    
    --accent-emerald: #059669;    /* Clean Farm Green 600 */
    --accent-emerald-subtle: #d1fae5;
    
    --accent-amber: #d97706;      /* Warning Amber 600 */
    --accent-amber-subtle: #fef3c7;
    
    --accent-rose: #e11d48;       /* Danger / Reject Rose 600 */
    --accent-rose-subtle: #ffe4e6;
    
    --accent-indigo: #4f46e5;     /* Indigo 600 */
    --accent-indigo-subtle: #e0e7ff;
    
    /* Borders & Dividers */
    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 9999px;

    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Header & Top Bar */
.top-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.85rem 1.75rem;
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
    color: #ffffff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.brand-subtitle {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.role-selector-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card-subtle);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.role-select {
    border: none;
    background: transparent;
    font-weight: 600;
    color: var(--brand-primary);
    cursor: pointer;
    font-size: 0.82rem;
    outline: none;
}

/* Nav Tabs */
.main-nav {
    background: #ffffff;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 1.75rem;
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
}

.nav-tab {
    padding: 0.85rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    border: none;
    background: transparent;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--brand-primary);
}

.nav-tab.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

.nav-badge {
    background: var(--bg-card-subtle);
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
}

/* Main Container */
.main-content {
    max-width: 1440px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Page Header */
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-title-group h2 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.view-title-group p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.view-actions {
    display: flex;
    gap: 0.65rem;
}

/* KPI Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kpi-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.kpi-blue { background: var(--brand-primary-subtle); color: var(--brand-primary); }
.kpi-green { background: var(--accent-emerald-subtle); color: var(--accent-emerald); }
.kpi-amber { background: var(--accent-amber-subtle); color: var(--accent-amber); }
.kpi-indigo { background: var(--accent-indigo-subtle); color: var(--accent-indigo); }
.kpi-rose { background: var(--accent-rose-subtle); color: var(--accent-rose); }

.kpi-info .kpi-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-info .kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin-top: 0.2rem;
}

.kpi-info .kpi-subtext {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* Cards & Containers */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.35rem;
}

/* Data Tables */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.data-table th {
    background: var(--bg-card-subtle);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges & Status Pills */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.badge-pending { background: var(--accent-amber-subtle); color: #b45309; }
.badge-approved, .badge-in-progress, .badge-active, .badge-fulfilled, .badge-paid { background: var(--accent-emerald-subtle); color: #047857; }
.badge-rejected, .badge-cancelled { background: var(--accent-rose-subtle); color: #be123c; }
.badge-harvested { background: #e0f2fe; color: #0369a1; }
.badge-closed { background: #e2e8f0; color: #475569; }
.badge-partially-fulfilled, .badge-partially-paid { background: #fef3c7; color: #92400e; }
.badge-due { background: #ffe4e6; color: #9f1239; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.5rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
}

.btn-primary {
    background: var(--brand-primary);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(2, 132, 199, 0.2);
}

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

.btn-secondary {
    background: #ffffff;
    color: var(--text-secondary);
    border-color: var(--border-subtle);
}

.btn-secondary:hover {
    background: var(--bg-card-subtle);
    color: var(--text-primary);
}

.btn-success {
    background: var(--accent-emerald);
    color: #ffffff;
}

.btn-success:hover {
    background: #047857;
}

.btn-danger {
    background: var(--accent-rose);
    color: #ffffff;
}

.btn-danger:hover {
    background: #be123c;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-modal-backdrop);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1.25rem;
}

.modal-overlay.active {
    display: flex;
    animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content {
    background: #ffffff;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-subtle);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close-btn {
    border: none;
    background: transparent;
    font-size: 1.35rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    background: #f8fafc;
    border-bottom-left-radius: var(--radius-xl);
    border-bottom-right-radius: var(--radius-xl);
}

/* Forms */
.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-size: 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: #ffffff;
    color: var(--text-primary);
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
}

.form-help {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Timeline / History List */
.history-timeline {
    position: relative;
    padding-left: 1.5rem;
    margin-top: 0.5rem;
}

.history-timeline::before {
    content: '';
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 6px;
    width: 2px;
    background: var(--border-subtle);
}

.timeline-item {
    position: relative;
    margin-bottom: 1rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--brand-primary);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 2px var(--border-subtle);
}

.timeline-item.rejected::before {
    background: var(--accent-rose);
}

.timeline-item.approved::before {
    background: var(--accent-emerald);
}

.timeline-content {
    background: var(--bg-card-subtle);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

/* Story Walkthrough Cards */
.story-step-card {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}

.story-step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-primary-subtle);
    color: var(--brand-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.story-step-body {
    flex-grow: 1;
}

.story-step-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.story-step-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.story-step-db {
    margin-top: 0.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    background: #f1f5f9;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    color: #0369a1;
    display: inline-block;
}

/* Alert Boxes */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-info {
    background: var(--brand-primary-subtle);
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.alert-warning {
    background: var(--accent-amber-subtle);
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-danger {
    background: var(--accent-rose-subtle);
    color: #9f1239;
    border: 1px solid #fecdd3;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    padding: 0.75rem 1.15rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: toastIn 0.25s ease-out;
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-rose); }
.toast.info { border-left: 4px solid var(--brand-primary); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Code Pre blocks for ERD & SQL viewer */
pre.code-block {
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    padding: 1rem;
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    overflow-x: auto;
    color: var(--text-secondary);
    line-height: 1.5;
}
