/* ============================================
   D & D Seafood — Main Stylesheet
   Based on BCQ architecture, ocean/teal theme
   ============================================ */

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

:root {
    --primary: #0d4f4f;
    --primary-light: #1a7a7a;
    --primary-dark: #083535;
    --accent: #e8913a;
    --accent-hover: #d17e2e;
    --bg: #f0f7f7;
    --card: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #666666;
    --text-light: #999999;
    --border: #d4e6e6;
    --border-light: #e8f0f0;
    --success: #22c55e;
    --success-bg: #dcfce7;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #0ea5e9;
    --info-bg: #e0f2fe;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 0.2s ease;
    --sidebar-width: 250px;
}

html { font-size: 15px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--accent); }

h1 { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
h2 { font-size: 1.4rem; font-weight: 600; color: var(--primary); }
h3 { font-size: 1.1rem; font-weight: 600; }

.hidden { display: none !important; }
.text-secondary { color: var(--text-secondary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

/* Auth */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    padding: 2rem;
}

.auth-card {
    background: var(--card);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-card .logo { text-align: center; margin-bottom: 2rem; }
.auth-card .logo h2 { color: var(--primary); font-size: 1.5rem; }
.auth-card .logo p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.25rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); background: var(--bg); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1.05rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(26, 122, 122, 0.12);
}

.form-control::placeholder { color: var(--text-light); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

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

.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}
.sidebar-header h2 { color: #fff; font-size: 1.2rem; font-weight: 700; }
.sidebar-header p { color: rgba(255,255,255,0.5); font-size: 0.75rem; margin-top: 0.15rem; }

.sidebar-nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    color: rgba(255,255,255,0.7);
    font-size: 1.15rem;
    font-weight: 600;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,0.05); }
.sidebar-nav a.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-left-color: var(--accent);
}
.sidebar-nav a .nav-icon { font-size: 1.4rem; width: 28px; text-align: center; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-footer a { color: rgba(255,255,255,0.6); font-size: 0.85rem; display: flex; align-items: center; gap: 0.5rem; }
.sidebar-footer a:hover { color: #fff; }

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

.topbar {
    background: var(--card);
    padding: 0.85rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-left h1 { font-size: 1.25rem; }

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text);
    cursor: pointer;
    padding: 0.25rem;
}

.topbar-right { display: flex; align-items: center; gap: 1rem; }
.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.user-menu:hover { background: var(--bg); }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.page-content { padding: 2rem; max-width: 1400px; }

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-body { padding: 1.5rem; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.teal { background: #ccfbf1; color: #0d9488; }

.stat-info h3 { font-size: 2.5rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-info p { font-size: 1rem; font-weight: 700; color: var(--text-secondary); margin-top: 0.25rem; }

/* Tables */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    background: var(--bg);
}
.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    vertical-align: middle;
}
.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: var(--bg); }
.data-table .row-actions { display: flex; gap: 0.35rem; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--card);
    border-radius: 12px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.25s;
}
.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 1.15rem; }
.modal-close {
    background: none; border: none; font-size: 1.4rem;
    color: var(--text-secondary); cursor: pointer; padding: 0.25rem; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}
.modal-lg { max-width: 800px; }

/* Toast */
.toast-container {
    position: fixed;
    top: 1rem; right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.25rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    max-width: 400px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast-message { flex: 1; font-size: 0.9rem; }
.toast-close { background: none; border: none; color: var(--text-light); cursor: pointer; font-size: 1.1rem; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Spinner */
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
    gap: 1rem;
}

/* Empty */
.empty-state { text-align: center; padding: 3rem 2rem; color: var(--text-secondary); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }
.empty-state p { margin-bottom: 1.5rem; font-size: 0.9rem; }

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.toolbar-left { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 0.75rem; align-items: center; }

.search-input { position: relative; }
.search-input input { padding-left: 2.25rem; min-width: 250px; }
.search-input .search-icon {
    position: absolute; left: 0.75rem; top: 50%;
    transform: translateY(-50%); color: var(--text-light); font-size: 0.9rem;
}

/* Line Items */
.line-items-table { width: 100%; border-collapse: collapse; margin-bottom: 0.5rem; }
.line-items-table th {
    text-align: left; padding: 0.5rem; font-size: 0.8rem; font-weight: 600;
    color: var(--text-secondary); border-bottom: 1px solid var(--border);
}
.line-items-table td { padding: 0.35rem; }
.line-items-table input { width: 100%; }
.line-items-table .col-species { width: 30%; }
.line-items-table .col-weight { width: 20%; }
.line-items-table .col-price { width: 20%; }
.line-items-table .col-amt { width: 20%; text-align: right; padding: 0.5rem; font-weight: 600; }
.line-items-table .col-action { width: 10%; text-align: center; }

.line-total {
    text-align: right;
    padding: 0.75rem 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    border-top: 2px solid var(--primary);
}

/* Detail */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.detail-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-section { margin-bottom: 1.5rem; }
.detail-section h4 {
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-secondary); margin-bottom: 0.75rem;
    padding-bottom: 0.35rem; border-bottom: 1px solid var(--border-light);
}

.detail-field { margin-bottom: 0.5rem; }
.detail-field .label { font-size: 0.8rem; color: var(--text-secondary); }
.detail-field .value { font-weight: 500; }

/* Badge */
.badge {
    display: inline-flex; align-items: center;
    padding: 0.2rem 0.7rem; border-radius: 50px;
    font-size: 0.75rem; font-weight: 600;
}
.badge-admin { background: var(--info-bg); color: var(--info); }
.badge-bookkeeper { background: var(--warning-bg); color: #b45309; }

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

/* Divider */
.divider { height: 1px; background: var(--border-light); margin: 1.5rem 0; }

/* Autocomplete dropdown */
.ac-dropdown {
    position: absolute;
    z-index: 999;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 2px;
}
.ac-dropdown div {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
}
.ac-dropdown div:hover { background: var(--bg); }

/* Page transition */
.page-enter { animation: fadeUp 0.3s ease; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.clickable { cursor: pointer; }
.money { font-family: 'Inter', monospace; }

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0; }
    .hamburger { display: block; }
    .page-content { padding: 1.25rem; }
    .topbar { padding: 0.75rem 1.25rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .stat-info h3 { font-size: 1rem; }
    .stat-card { padding: 0.6rem; min-width: 0; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .form-control, input, select, textarea { font-size: 16px !important; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left, .toolbar-right { width: 100%; }
    .search-input input { min-width: 0; width: 100%; }

    .data-table thead { display: none; }
    .data-table tbody tr {
        display: block; padding: 1rem; margin-bottom: 0.75rem;
        border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--card);
    }
    .data-table td {
        display: flex; justify-content: space-between; padding: 0.35rem 0; border: none;
    }
    .data-table td::before {
        content: attr(data-label); font-weight: 600; font-size: 0.8rem;
        color: var(--text-secondary); text-transform: uppercase;
    }
}

/* Mobile dashboard layout fix */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; max-width: 100%; box-sizing: border-box; }
    .stat-card { padding: 0.6rem; min-width: 0; overflow: hidden; }
    .stat-info h3 { font-size: 1.2rem; }
    .stat-info p { font-size: 0.65rem; }
    .stat-icon { font-size: 1.2rem; width: 32px; height: 32px; min-width: 32px; }
    .detail-grid { grid-template-columns: 1fr; }
    .card table { width: 100%; }
    .data-table td { word-break: normal; }
}

/* Mobile stat card money overflow fix */
@media (max-width: 768px) {
    .stat-info h3 { font-size: 1rem; white-space: nowrap; overflow: visible; }
    .stat-card { gap: 0.4rem; }
}
@media (max-width: 380px) {
    .stat-info h3 { font-size: 0.9rem; }
}
