/* CleanPro CRM — Dark Professional Theme */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161922;
    --bg-card: #1c1f2e;
    --bg-sidebar: #111320;
    --bg-input: #1e2235;
    --border: #2a2d3e;
    --border-light: #333650;
    --text-primary: #e8eaf0;
    --text-secondary: #8b8fa3;
    --text-muted: #5c6078;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-soft: rgba(59,130,246,0.12);
    --green: #22c55e;
    --green-soft: rgba(34,197,94,0.12);
    --yellow: #f59e0b;
    --yellow-soft: rgba(245,158,11,0.12);
    --red: #ef4444;
    --red-soft: rgba(239,68,68,0.12);
    --purple: #a855f7;
    --purple-soft: rgba(168,85,247,0.12);
    --cyan: #06b6d4;
    --cyan-soft: rgba(6,182,212,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.25);
    --sidebar-width: 260px;
    --font: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 0;
    min-width: 0;
}

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

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 24px 28px;
}

.logo-icon {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(59,130,246,0.3);
}

.logo-text {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #e8eaf0, #8b8fa3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14.5px;
    transition: all 0.2s ease;
    position: relative;
}

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

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 24px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    flex-shrink: 0;
}

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

.sidebar-version {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============ TOP BAR ============ */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 36px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-logout {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    transition: color 0.2s;
}

.btn-logout:hover {
    color: var(--red);
}

/* ============ PAGE HEADER ============ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ============ CARDS ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--border-light);
}

/* ============ STAT CARDS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    border-radius: 0 0 0 80px;
    opacity: 0.06;
}

.stat-card.blue::after { background: var(--accent); }
.stat-card.green::after { background: var(--green); }
.stat-card.yellow::after { background: var(--yellow); }
.stat-card.purple::after { background: var(--purple); }
.stat-card.cyan::after { background: var(--cyan); }
.stat-card.red::after { background: var(--red); }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.stat-icon.blue { background: var(--accent-soft); color: var(--accent); }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.yellow { background: var(--yellow-soft); color: var(--yellow); }
.stat-icon.purple { background: var(--purple-soft); color: var(--purple); }
.stat-icon.cyan { background: var(--cyan-soft); color: var(--cyan); }
.stat-icon.red { background: var(--red-soft); color: var(--red); }

.stat-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============ TABLE ============ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 14px 18px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 14px 18px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

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

tr:hover td {
    background: rgba(59,130,246,0.03);
}

/* ============ BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-new { background: var(--accent-soft); color: var(--accent); }
.badge-confirmed { background: var(--cyan-soft); color: var(--cyan); }
.badge-progress { background: var(--yellow-soft); color: var(--yellow); }
.badge-completed { background: var(--green-soft); color: var(--green); }
.badge-cancelled { background: var(--red-soft); color: var(--red); }
.badge-active { background: var(--green-soft); color: var(--green); }
.badge-inactive { background: var(--red-soft); color: var(--red); }
.badge-low { background: var(--red-soft); color: var(--red); }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-in { background: var(--green-soft); color: var(--green); }
.badge-out { background: var(--red-soft); color: var(--red); }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(59,130,246,0.3); }

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-light); background: var(--bg-secondary); }

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

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

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
}
.btn-icon:hover { background: var(--bg-input); color: var(--text-primary); }

.actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ============ FORMS ============ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 11px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

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

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%238b8fa3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

/* ============ MODAL ============ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 90%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalIn 0.25s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 24px;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}
.modal-close:hover { color: var(--text-primary); }

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ============ ALERTS ============ */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: var(--green-soft); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.alert-error { background: var(--red-soft); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.alert-info { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(59,130,246,0.2); }

/* ============ CHARTS / MINI BAR ============ */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.chart-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.mini-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 120px;
}

.mini-bar {
    flex: 1;
    background: var(--accent-soft);
    border-radius: 6px 6px 0 0;
    position: relative;
    min-height: 4px;
    transition: height 0.5s ease;
}

.mini-bar-inner {
    width: 100%;
    background: var(--accent);
    border-radius: 6px 6px 0 0;
    position: absolute;
    bottom: 0;
    transition: height 0.5s ease;
}

.mini-bar-label {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
}

/* ============ SCHEDULE CALENDAR ============ */
.schedule-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.schedule-day {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    min-height: 100px;
    font-size: 13px;
}

.schedule-day.today {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.schedule-day-num {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.schedule-day.today .schedule-day-num {
    color: var(--accent);
}

.schedule-event {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.schedule-event:hover {
    background: var(--accent);
    color: #fff;
}

.schedule-event.completed { background: var(--green-soft); color: var(--green); }
.schedule-event.completed:hover { background: var(--green); color: #fff; }
.schedule-event.cancelled { background: var(--red-soft); color: var(--red); }

.weekday-header {
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px;
}

/* ============ FILTERS BAR ============ */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filters-bar select,
.filters-bar input {
    width: auto;
    min-width: 180px;
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 15px; }

/* ============ LOGIN PAGE ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo .logo-icon {
    margin: 0 auto 16px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 6px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 15px;
    margin-top: 8px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: flex;
    }
    .page-content {
        padding: 20px 16px;
    }
    .top-bar {
        padding: 12px 16px;
    }
}

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr; }
    .chart-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .schedule-grid { grid-template-columns: repeat(2, 1fr); }
    .page-title { font-size: 22px; }
    .modal { padding: 24px 20px; }
    table { font-size: 13px; }
    th, td { padding: 10px 12px; }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============ TRANSACTION LIST (warehouse) ============ */
.transaction-list {
    max-height: 300px;
    overflow-y: auto;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.transaction-item:last-child { border-bottom: none; }

/* ============ PROGRESS BAR (for stock levels) ============ */
.stock-bar {
    width: 80px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
}

.stock-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.stock-bar-fill.ok { background: var(--green); }
.stock-bar-fill.low { background: var(--yellow); }
.stock-bar-fill.critical { background: var(--red); }

/* ============ ANIMATION ============ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-content {
    animation: fadeIn 0.3s ease;
}

/* ============ PAGINATION ============ */
.pagination {
    display: flex;
    gap: 4px;
    margin-top: 20px;
    justify-content: center;
    align-items: center;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: var(--bg-input);
    transition: all 0.2s;
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============ TABS ============ */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}

.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
