/*
 * Ылдам Экспресс — стили интерфейса
 * Автор: Мурзапаров Нурсайид Нурланбекович
 */

:root {
    --primary: #2457d6;
    --primary-dark: #1b40a0;
    --primary-soft: #eaf0fe;
    --accent: #f59e0b;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e5e9f0;

    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --info: #0284c7;
    --info-bg: #e0f2fe;

    --sidebar-w: 264px;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
    --ring: 0 0 0 3px rgba(36, 87, 214, .18);
}

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

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto,
        'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0f172a 0%, #16223b 100%);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    border-right: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(36, 87, 214, .4);
}

.sidebar-header h2 {
    font-size: 19px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .2px;
}

.sidebar-subtitle {
    font-size: 11.5px;
    color: #94a3b8;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 500;
    transition: background .18s, color .18s;
}

.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 6px 16px rgba(36, 87, 214, .35);
}

.nav-icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 12px;
}

.sidebar-user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-name { font-size: 14px; color: #f1f5f9; font-weight: 600; }
.sidebar-user-role { font-size: 11px; color: #94a3b8; }

.sidebar-logout {
    display: block;
    padding: 9px 12px;
    background: rgba(220, 38, 38, .14);
    color: #fca5a5;
    border: 1px solid rgba(220, 38, 38, .28);
    border-radius: 9px;
    text-decoration: none;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    transition: all .18s;
}

.sidebar-logout:hover { background: rgba(220, 38, 38, .26); color: #fff; }

/* ===== MAIN ===== */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(8px);
    padding: 18px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title { font-size: 22px; font-weight: 700; }

.user-info {
    color: var(--muted);
    font-size: 14px;
    background: var(--bg);
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.content-wrapper { flex: 1; padding: 28px 32px; max-width: 1320px; width: 100%; }

.footer {
    padding: 18px 32px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
}

/* ===== FLASH ===== */
.flash-messages { padding: 22px 32px 0; }

.alert {
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    border: 1px solid transparent;
    animation: slidein .25s ease;
}

@keyframes slidein {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.alert-error { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    opacity: .55;
    padding: 0 0 0 14px;
}
.close-btn:hover { opacity: 1; }

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.card-header {
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title { font-size: 18px; font-weight: 700; }

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.stat-card-title {
    font-size: 12.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    font-weight: 600;
}

.stat-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-card-value { font-size: 30px; font-weight: 800; color: var(--primary); }

.stat-card-success { border-top: 3px solid var(--success); }
.stat-card-success .stat-card-value { color: var(--success); }
.stat-card-success .stat-card-icon { background: var(--success-bg); }

.stat-card-warning { border-top: 3px solid var(--warning); }
.stat-card-warning .stat-card-value { color: var(--warning); }
.stat-card-warning .stat-card-icon { background: var(--warning-bg); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
    font-size: 13.5px;
    color: #334155;
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color .18s, box-shadow .18s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .18s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

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

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

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

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

.btn-secondary { background: #eef2f7; color: #334155; border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

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

/* ===== TABLES ===== */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

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

.table thead { background: #f8fafc; }

.table th {
    padding: 13px 16px;
    text-align: left;
    font-weight: 700;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}

.table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

.mono { font-family: 'Consolas', 'SF Mono', monospace; font-size: 13px; color: var(--muted); }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: #166534; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-info { background: var(--info-bg); color: #075985; }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }

.type-badge { display: inline-block; padding: 3px 10px; border-radius: 7px; font-size: 12px; font-weight: 600; }
.type-документы { background: #e2e8f0; color: #334155; }
.type-посылка { background: var(--primary-soft); color: var(--primary-dark); }
.type-груз { background: var(--warning-bg); color: #92400e; }

/* ===== STATUS SELECT ===== */
.status-select {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
}
.status-select:focus-visible { outline: none; box-shadow: var(--ring); }
.status-select-новое { border-color: #bae6fd; background: var(--info-bg); color: #075985; }
.status-select-в-пути { border-color: #fde68a; background: var(--warning-bg); color: #92400e; }
.status-select-доставлено { border-color: #bbf7d0; background: var(--success-bg); color: #166534; }

/* ===== LOGIN ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1b40a0 55%, #2457d6 100%);
}

.login-box {
    background: var(--surface);
    padding: 42px 38px;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    width: 100%;
    max-width: 410px;
}

.login-logo {
    width: 60px;
    height: 60px;
    margin: 0 auto 18px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    box-shadow: 0 10px 24px rgba(36, 87, 214, .4);
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-header h1 { font-size: 25px; font-weight: 800; }
.login-header p { color: var(--muted); font-size: 14px; margin-top: 6px; }

.login-hint {
    margin-top: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
}

/* ===== CALCULATOR RESULT ===== */
.calculator-result {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 36px;
    border-radius: var(--radius);
    margin-top: 24px;
    text-align: center;
}

.calculator-result-price {
    font-size: 52px;
    font-weight: 800;
    margin: 12px 0;
    letter-spacing: -1px;
}

.calculator-result-details { font-size: 15px; opacity: .92; }

.btn-light {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .35);
    padding: 11px 22px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    font-weight: 600;
    transition: background .18s;
}
.btn-light:hover { background: rgba(255, 255, 255, .3); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 30px; color: var(--muted); }
.empty-state-icon { font-size: 52px; margin-bottom: 14px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 14px; margin-bottom: 18px; }

/* ===== ERROR PAGE ===== */
.error-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--bg);
    padding: 20px;
}
.error-code { font-size: 96px; font-weight: 800; color: var(--primary); line-height: 1; }
.error-message { font-size: 19px; color: var(--muted); margin: 12px 0 26px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 860px) {
    .sidebar { width: 72px; }
    .sidebar-header { justify-content: center; padding: 18px 0; }
    .sidebar-header h2, .sidebar-subtitle,
    .nav-item span:not(.nav-icon),
    .sidebar-user > div, .sidebar-logout { display: none; }
    .sidebar-header { gap: 0; }
    .nav-item { justify-content: center; padding: 12px; }
    .sidebar-user { justify-content: center; }
    .main-content { margin-left: 72px; }
    .content-wrapper, .top-bar, .flash-messages, .footer { padding-left: 18px; padding-right: 18px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .calculator-result-price { font-size: 40px; }
    .page-title { font-size: 18px; }
}
