/* ============================================
   Brand Must Home - Workflow Management System
   Mobile-First, Minimalist, Professional
   ============================================ */

/* Import Poppins font */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

/* ---- CSS Variables ---- */
:root {
    --bg: #FFFFFF;
    --bg-secondary: #F9FAFB;
    --text-primary: #1A1A1A;
    --text-secondary: #333333;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --border-input: #D1D5DB;
    --btn-primary: #6B7280;
    --btn-primary-hover: #374151;
    --btn-secondary: #9CA3AF;
    --btn-secondary-hover: #6B7280;
    --accent-red: #DC2626;
    --accent-amber: #F59E0B;
    --accent-green: #10B981;
    --accent-blue: #3B82F6;
    --sidebar-width: 260px;
    --header-height: 56px;
    --radius: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --transition: 0.2s ease;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--btn-primary-hover);
}

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

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: -var(--sidebar-width);
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg);
    border-right: 1px solid var(--border);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header h1 {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-header .logo {
    width: 32px;
    height: 32px;
    background: var(--text-primary);
    color: var(--bg);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

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

/* Old static section label (kept for backwards compat) */
.nav-section {
    padding: 8px 20px 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* ── Accordion navigation ── */
.nav-accordion {
    border-top: 1px solid var(--border);
}

.nav-accordion:first-of-type {
    border-top: none;
}

.nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: all var(--transition);
    min-height: 40px;
}

.nav-section-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.nav-section-toggle.open {
    color: var(--text-primary);
}

.nav-arrow {
    font-size: 0.625rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.nav-section-toggle.open .nav-arrow {
    transform: rotate(90deg);
}

.nav-accordion-body {
    display: none;
    padding-bottom: 4px;
}

.nav-accordion-body .nav-item {
    padding-left: 28px;
    font-size: 0.8125rem;
    min-height: 38px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 400;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    min-height: 44px;
}

.nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-item.active {
    background: #F3F4F6;
    color: var(--text-primary);
    font-weight: 500;
    border-left-color: var(--text-primary);
}

.nav-item .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent-red);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer .user-avatar {
    width: 32px;
    height: 32px;
    background: var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--text-primary);
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    min-width: 0;
    width: 100%;
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1.25rem;
    border-radius: var(--radius);
    flex-shrink: 0;
}

.hamburger:hover {
    background: var(--bg-secondary);
}

.header-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.notification-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.125rem;
    border-radius: var(--radius);
}

.notification-bell:hover {
    background: var(--bg-secondary);
}

.notification-bell .badge-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    border: 2px solid var(--bg);
}

.page-content {
    padding: 16px;
}

/* ---- Cards ---- */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.card-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2,
.card-header h3 {
    margin: 0;
    font-size: 0.9375rem;
}

.card-body {
    padding: 16px;
}

.card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    min-height: 44px;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--btn-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
    color: #fff;
}

.btn-secondary {
    background: var(--btn-secondary);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--btn-secondary-hover);
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-input);
}

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

.btn-danger {
    background: var(--accent-red);
    color: #fff;
}

.btn-danger:hover {
    background: #B91C1C;
    color: #fff;
}

.btn-success {
    background: var(--accent-green);
    color: #fff;
}

.btn-success:hover {
    background: #059669;
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8125rem;
    min-height: 36px;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.75rem;
    min-height: 28px;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg);
    border: 1px solid var(--border-input);
    border-radius: var(--radius);
    transition: border-color var(--transition);
    min-height: 44px;
}

.form-control:focus {
    outline: none;
    border-color: var(--btn-primary);
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.15);
}

.form-control::placeholder {
    color: var(--btn-secondary);
}

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

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='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--btn-primary);
}

.form-error {
    font-size: 0.8125rem;
    color: var(--accent-red);
    margin-top: 4px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 0;
}

/* ---- Tables ---- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

.table tbody tr:hover {
    background: var(--bg-secondary);
}

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

/* Mobile card view for tables */
.mobile-cards {
    display: block;
}

.mobile-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.875rem;
}

.mobile-card-row .label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.desktop-table {
    display: none;
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 12px;
    white-space: nowrap;
}

.badge-default {
    background: #F3F4F6;
    color: var(--text-secondary);
}

.badge-info {
    background: #EFF6FF;
    color: var(--accent-blue);
    border-left: 3px solid var(--accent-blue);
}

.badge-success {
    background: #ECFDF5;
    color: var(--accent-green);
    border-left: 3px solid var(--accent-green);
}

.badge-warning {
    background: #FFFBEB;
    color: #D97706;
    border-left: 3px solid var(--accent-amber);
}

.badge-danger {
    background: #FEF2F2;
    color: var(--accent-red);
    border-left: 3px solid var(--accent-red);
}

/* Priority indicators */
.priority-high {
    border-left: 3px solid var(--accent-amber) !important;
}

.priority-urgent {
    border-left: 3px solid var(--accent-red) !important;
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0%, 100% { border-left-color: var(--accent-red); }
    50% { border-left-color: transparent; }
}

/* ---- Flash Messages ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-warning {
    background: #FFFBEB;
    color: #92400E;
    border: 1px solid #FDE68A;
}

.alert-info {
    background: #EFF6FF;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

/* ---- Stats Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 1.25rem;
}

.page-header .page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- Pagination ---- */
.pagination-wrap {
    display: flex;
    justify-content: center;
    padding: 16px 0;
}

.pagination {
    display: flex;
    list-style: none;
    gap: 4px;
}

.page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all var(--transition);
}

.page-item .page-link:hover {
    background: var(--bg-secondary);
}

.page-item.active .page-link {
    background: var(--btn-primary);
    color: #fff;
    border-color: var(--btn-primary);
}

.page-item.disabled .page-link {
    color: var(--btn-secondary);
    pointer-events: none;
}

/* ---- Filters bar ---- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.filters-bar .form-control {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.875rem;
}

/* ---- Timeline ---- */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--btn-secondary);
    border: 2px solid var(--bg);
}

.timeline-item.current::before {
    background: var(--accent-green);
}

.timeline-item .timeline-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.timeline-item .timeline-text {
    font-size: 0.875rem;
    margin-top: 2px;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.875rem;
}

/* ---- Loading ---- */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--btn-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- FAB (Floating Action Button) ---- */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--btn-primary);
    color: #fff;
    border: none;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 50;
    transition: all var(--transition);
}

.fab:hover {
    background: var(--btn-primary-hover);
    transform: scale(1.05);
}

/* ---- Utility ---- */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--accent-red); }
.text-success { color: var(--accent-green); }
.text-warning { color: #D97706; }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ============================================
   DESKTOP BREAKPOINTS
   ============================================ */

/* Tablet (768px+) */
@media (min-width: 768px) {
    html {
        font-size: 14px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .form-row .form-group {
        min-width: 200px;
    }

    .page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .page-content {
        padding: 24px;
    }

    .mobile-cards {
        display: none;
    }

    .desktop-table {
        display: block;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
        position: fixed;
        left: 0;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .hamburger {
        display: none;
    }

    .main-content {
        margin-left: var(--sidebar-width);
    }

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

/* Large Desktop (1280px+) */
@media (min-width: 1280px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}
