/* ============================================================
   WorkNest – Custom Stylesheet (layered on top of Bootstrap 5)
   ============================================================ */

/* ---------- Variables ---------- */
:root {
    --wn-primary:   #2563eb;
    --wn-secondary: #64748b;
    --wn-success:   #16a34a;
    --wn-danger:    #dc2626;
    --wn-warning:   #d97706;
    --wn-info:      #0891b2;
    --wn-light:     #f8fafc;
    --wn-dark:      #1e293b;
    --wn-border:    #e2e8f0;
    --wn-sidebar-w: 240px;
    --wn-radius:    0.5rem;
    --wn-shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--wn-light);
    color: var(--wn-dark);
    min-height: 100vh;
}

a { color: var(--wn-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.wn-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.wn-sidebar {
    width: var(--wn-sidebar-w);
    background: var(--wn-dark);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform .25s ease;
}

.wn-sidebar-brand {
    padding: 1.25rem 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.wn-sidebar-brand svg { flex-shrink: 0; }

.wn-nav { padding: .75rem 0; }

.wn-nav-label {
    padding: .35rem 1.5rem;
    font-size: .65rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
}

.wn-nav a {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem 1.5rem;
    color: #94a3b8;
    font-size: .875rem;
    transition: background .15s, color .15s;
    text-decoration: none;
}

.wn-nav a:hover, .wn-nav a.active {
    background: rgba(255,255,255,.07);
    color: #fff;
}

.wn-nav a.active { border-left: 3px solid var(--wn-primary); }

.wn-sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .8rem;
    color: #64748b;
}

/* Main content */
.wn-main {
    margin-left: var(--wn-sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.wn-topbar {
    background: #fff;
    border-bottom: 1px solid var(--wn-border);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.wn-topbar-title { font-weight: 600; font-size: 1rem; }

.wn-content {
    padding: 1.75rem 1.5rem;
    flex: 1;
}

/* ---------- Cards ---------- */
.wn-card {
    background: #fff;
    border: 1px solid var(--wn-border);
    border-radius: var(--wn-radius);
    box-shadow: var(--wn-shadow);
}

.wn-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--wn-border);
    font-weight: 600;
    font-size: .9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.wn-card-body { padding: 1.25rem; }

/* ---------- Stat boxes ---------- */
.wn-stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.wn-stat {
    background: #fff;
    border: 1px solid var(--wn-border);
    border-radius: var(--wn-radius);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--wn-shadow);
}

.wn-stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.wn-stat-label { font-size: .78rem; color: var(--wn-secondary); margin-top: .25rem; }

.wn-stat-danger  { border-top: 3px solid var(--wn-danger);  }
.wn-stat-warning { border-top: 3px solid var(--wn-warning); }
.wn-stat-info    { border-top: 3px solid var(--wn-info);    }
.wn-stat-primary { border-top: 3px solid var(--wn-primary); }
.wn-stat-success { border-top: 3px solid var(--wn-success); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: .28em .55em; border-radius: 99px; font-size: .72em; font-weight: 600; white-space: nowrap; }

/* Status */
.badge-status-new          { background: #e2e8f0; color: #475569; }
.badge-status-in-progress  { background: #dbeafe; color: #1d4ed8; }
.badge-status-waiting      { background: #fef9c3; color: #854d0e; }
.badge-status-done         { background: #dcfce7; color: #166534; }
.badge-status-cancelled    { background: #fee2e2; color: #991b1b; }

/* Priority */
.badge-priority-low    { background: #f1f5f9; color: #64748b; }
.badge-priority-medium { background: #e0f2fe; color: #0369a1; }
.badge-priority-high   { background: #fef3c7; color: #92400e; }
.badge-priority-urgent { background: #fee2e2; color: #991b1b; }

/* Visibility */
.badge-public  { background: #dcfce7; color: #166534; }
.badge-private { background: #f5f3ff; color: #5b21b6; }

/* ---------- Table ---------- */
.wn-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.wn-table th, .wn-table td { padding: .65rem .9rem; text-align: left; border-bottom: 1px solid var(--wn-border); }
.wn-table th { background: #f8fafc; font-weight: 600; font-size: .78rem; letter-spacing: .03em; color: var(--wn-secondary); }
.wn-table tr:hover td { background: #f8fafc; }
.wn-table tr:last-child td { border-bottom: none; }
.wn-table .actions { white-space: nowrap; }

/* ---------- Forms ---------- */
.form-control, .form-select {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--wn-border);
    border-radius: var(--wn-radius);
    font-size: .875rem;
    background: #fff;
    color: var(--wn-dark);
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--wn-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

textarea.form-control { resize: vertical; min-height: 100px; }

.form-label { font-size: .85rem; font-weight: 500; margin-bottom: .3rem; display: block; }
.form-text  { font-size: .75rem; color: var(--wn-secondary); margin-top: .25rem; }
.form-group { margin-bottom: 1rem; }

.form-row { display: grid; gap: 1rem; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .9rem;
    border: 1px solid transparent;
    border-radius: var(--wn-radius);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: filter .15s, box-shadow .15s;
    white-space: nowrap;
}

.btn:hover { filter: brightness(.92); text-decoration: none; }
.btn:active { filter: brightness(.86); }

.btn-primary   { background: var(--wn-primary);   color: #fff; }
.btn-secondary { background: var(--wn-secondary); color: #fff; }
.btn-success   { background: var(--wn-success);   color: #fff; }
.btn-danger    { background: var(--wn-danger);     color: #fff; }
.btn-warning   { background: var(--wn-warning);    color: #fff; }
.btn-light     { background: #f1f5f9; color: var(--wn-dark); border-color: var(--wn-border); }
.btn-sm        { padding: .28rem .6rem; font-size: .78rem; }
.btn-xs        { padding: .18rem .45rem; font-size: .72rem; }

/* ---------- Alerts ---------- */
.alert {
    padding: .875rem 1rem;
    border-radius: var(--wn-radius);
    margin-bottom: 1rem;
    font-size: .875rem;
    border: 1px solid transparent;
}

.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fef9c3; color: #854d0e; border-color: #fef08a; }
.alert-info    { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }

/* ---------- Public (external) form ---------- */
.wn-public {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
}

.wn-public-box {
    background: #fff;
    border: 1px solid var(--wn-border);
    border-radius: 1rem;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 600px;
}

.wn-public-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}

.wn-public-logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--wn-primary);
    margin: 0;
}

.wn-public-logo p {
    color: var(--wn-secondary);
    font-size: .9rem;
    margin: .25rem 0 0;
}

/* ---------- Login ---------- */
.wn-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wn-dark);
    padding: 1rem;
}

.wn-login-box {
    background: #fff;
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 40px rgba(0,0,0,.2);
}

/* ---------- Filter bar ---------- */
.wn-filters {
    background: #fff;
    border: 1px solid var(--wn-border);
    border-radius: var(--wn-radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
}

.wn-filters .form-group { margin-bottom: 0; flex: 1 1 140px; }
.wn-filters .btn        { align-self: flex-end; }

/* ---------- Overdue indicator in tables ---------- */
.text-danger  { color: var(--wn-danger)  !important; }
.text-warning { color: var(--wn-warning) !important; }
.fw-bold      { font-weight: 700 !important; }

/* ---------- Mobile toggle ---------- */
.wn-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .4rem;
    color: var(--wn-dark);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .wn-sidebar {
        transform: translateX(-100%);
    }
    .wn-sidebar.open {
        transform: translateX(0);
    }
    .wn-main {
        margin-left: 0;
    }
    .wn-sidebar-toggle {
        display: flex;
    }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .wn-topbar { padding: .65rem 1rem; }
    .wn-content { padding: 1rem; }
    .wn-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .wn-stats { grid-template-columns: 1fr 1fr; }
    .wn-public-box { padding: 1.5rem 1.25rem; }
    .wn-table thead { display: none; }
    .wn-table tr { display: block; border-bottom: 2px solid var(--wn-border); padding: .5rem 0; }
    .wn-table td { display: flex; justify-content: space-between; padding: .3rem .6rem; border: none; }
    .wn-table td::before { content: attr(data-label); font-weight: 600; color: var(--wn-secondary); font-size: .75rem; }
}

/* ---------- Tag badges ---------- */
.tag-badge {
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 99px;
    padding: .25rem .6rem;
    font-size: .78rem;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}

.tag-badge button {
    background: none;
    border: none;
    cursor: pointer;
    color: #0369a1;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}

/* ---------- Utilities ---------- */
.text-muted  { color: var(--wn-secondary) !important; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mt-1 { margin-top: .5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.d-flex     { display: flex !important; }
.align-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.gap-1 { gap: .5rem !important; }
.gap-2 { gap: 1rem !important; }
.w-100  { width: 100% !important; }
.text-center { text-align: center !important; }
.text-right  { text-align: right !important; }
.small { font-size: .8rem; }

/* ---------- Sidebar overlay (mobile) ---------- */
.wn-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}
.wn-sidebar-overlay.open { display: block; }
