/* ============================================================
   Milk Collection SaaS – Advanced UI
   Design: Plus Jakarta Sans, slate/teal palette, soft depth
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
    /* Layout */
    --sidebar-width: 280px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
    --transition: 0.2s ease;

    /* Palette */
    --bg-app: #f1f5f9;
    --bg-card: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-bg-hover: #1e293b;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #f8fafc;
    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-light: rgba(13, 148, 136, 0.12);
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
}

* {
    box-sizing: border-box;
}

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

/* ----- Login page ----- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(13, 148, 136, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(13, 148, 136, 0.08) 0%, transparent 45%);
    pointer-events: none;
}

.login-page .login-grid {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
}

.login-card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.login-card .brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-card .brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0 0 0.25rem 0;
}

.login-card .brand p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.login-card .form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.login-card .form-control {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.login-card .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    outline: none;
}

.login-card .btn-login {
    width: 100%;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.9375rem;
    border-radius: var(--radius-sm);
    background: var(--accent);
    border: none;
    color: #fff;
    transition: background var(--transition), transform 0.1s;
}

.login-card .btn-login:hover {
    background: var(--accent-hover);
    color: #fff;
}

.login-card .btn-login:active {
    transform: scale(0.99);
}

.login-card .login-footer {
    text-align: center;
    margin-top: 1.25rem;
}

.login-card .login-footer a {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.login-card .login-footer a:hover {
    color: var(--accent);
}

.login-page .tagline {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.5);
}

.login-page .alert {
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

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

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, margin 0.25s ease;
    border-right: 1px solid var(--sidebar-border);
}

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

.sidebar-brand {
    color: var(--sidebar-text-active) !important;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand:hover {
    color: #fff !important;
}

.sidebar-close,
.sidebar-close:hover {
    color: var(--sidebar-text) !important;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.sidebar-close:hover {
    background: var(--sidebar-bg-hover);
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar-nav .nav-link {
    color: var(--sidebar-text);
    padding: 0.625rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 0 0.75rem 0 0;
    font-weight: 500;
    font-size: 0.875rem;
    transition: color var(--transition), background var(--transition);
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link i {
    font-size: 1.125rem;
    opacity: 0.85;
    width: 1.25rem;
    text-align: center;
}

.sidebar-nav .nav-link.active {
    background: rgba(13, 148, 136, 0.18);
    color: #5eead4;
    border-left: 3px solid var(--accent);
    margin-left: 0;
    padding-left: calc(1.25rem - 3px);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-footer .text-muted {
    color: var(--sidebar-text) !important;
    font-size: 0.8125rem;
}

.sidebar-footer .btn {
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    padding: 0 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.topbar .btn-link {
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.topbar .btn-link:hover {
    background: var(--bg-app);
    color: var(--accent);
}

.topbar h1 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.sidebar-brand i {
    font-size: 1.35rem;
    opacity: 0.95;
}

.content-inner {
    flex: 1;
    padding: 1.5rem;
    overflow-x: auto;
}

.app-footer {
    flex-shrink: 0;
    background: var(--bg-card);
}

/* ----- Cards ----- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: transparent;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    background: #fafafa;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* KPI cards */
.kpi-card {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow var(--transition);
}

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

.kpi-card .card-body {
    padding: 1.25rem;
}

.kpi-card .text-muted.small {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary) !important;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.kpi-card--accent {
    border-left: 4px solid var(--accent);
}

.kpi-card--accent .kpi-value {
    color: var(--accent);
}

/* ----- Tables ----- */
.table-responsive {
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

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

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

.table-light thead th {
    background: #f8fafc;
}

/* Mobile table cards */
.table-responsive-cards {
    overflow-x: auto;
}

@media (max-width: 767.98px) {
    .table thead {
        display: none;
    }
    .table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-bottom: 0.75rem;
        padding: 1rem;
        box-shadow: var(--shadow-sm);
        background: var(--bg-card);
    }
    .table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none;
        padding: 0.5rem 0;
    }
    .table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        margin-right: 0.5rem;
        font-size: 0.8125rem;
    }
}

/* ----- Buttons ----- */
.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-outline-primary {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent-hover);
}

.btn-group-actions .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.8125rem;
}

/* ----- Forms ----- */
.form-label {
    font-weight: 500;
    color: var(--text-primary);
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.9375rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    outline: none;
}

.form-select-sm,
.form-control-sm {
    border-radius: var(--radius-sm);
}

/* ----- Alerts ----- */
.alert {
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    border: none;
}

.alert-success {
    background: rgba(5, 150, 105, 0.12);
    color: #047857;
}

.alert-danger {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
}

.alert-warning {
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
}

/* ----- Badges ----- */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

.badge-pending {
    background: rgba(217, 119, 6, 0.2);
    color: #b45309;
}

.bg-success {
    background: var(--success) !important;
}

.bg-warning {
    background: var(--warning) !important;
}

.bg-secondary {
    background: var(--text-muted) !important;
}

/* ----- Page structure ----- */
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.page-actions .btn {
    font-size: 0.875rem;
}

/* ----- Utility ----- */
.min-vh-100 {
    min-height: 100vh;
}

/* ----- Print ----- */
@media print {
    .sidebar,
    .topbar,
    .btn,
    .no-print {
        display: none !important;
    }
    .content-inner {
        padding: 0;
    }
}

/* Mobile: sidebar overlay */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1050;
        margin-left: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .sidebar::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s;
    }
    .sidebar.show::after {
        opacity: 1;
        pointer-events: auto;
    }
    .content-inner {
        padding: 1rem;
    }
}
