/* ================================================
   KStud CRM — Styles
   ================================================ */

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

:root {
    --bg: #f8f9fb;
    --bg-card: #ffffff;
    --bg-dark: #0f1117;
    --text: #1a1d26;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #22c55e;
    --success-light: #f0fdf4;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #06b6d4;
    --purple: #8b5cf6;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.12);
    --transition: .2s cubic-bezier(.4,0,.2,1);
}

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

body {
    font-family: 'Onest', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ====== FORMS ====== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--bg-card);
    color: var(--text);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

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

/* ====== CARDS ====== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}
.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ====== TABLE ====== */
.table-wrap { overflow-x: auto; }
table.table {
    width: 100%;
    border-collapse: collapse;
}
table.table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 2px solid var(--border-light);
    white-space: nowrap;
}
table.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    vertical-align: middle;
}
table.table tbody tr { transition: background var(--transition); }
table.table tbody tr:hover { background: var(--primary-light); }

/* ====== DEADLINES ====== */
.deadline-ok { color: var(--success); }
.deadline-soon { color: var(--warning); font-weight: 600; }
.deadline-urgent { color: var(--danger); font-weight: 700; animation: pulse 1.5s ease infinite; }
.deadline-overdue { color: var(--danger); font-weight: 700; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}

/* ====== LANDING LAYOUT ====== */
.landing-hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #0f1117 0%, #1e293b 50%, #0f1117 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}
.landing-hero::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(37,99,235,.25) 0%, transparent 70%);
    top: -200px; right: -100px;
    pointer-events: none;
}
.landing-hero::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(139,92,246,.2) 0%, transparent 70%);
    bottom: -100px; left: -50px;
    pointer-events: none;
}
.landing-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
    position: relative;
    z-index: 1;
}
.landing-text h1 {
    font-size: clamp(32px, 5vw, 56px);
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 20px;
    letter-spacing: -.02em;
}
.landing-text h1 span { color: var(--primary); }
.landing-text p {
    font-size: 18px;
    color: rgba(255,255,255,.7);
    margin-bottom: 32px;
    max-width: 480px;
    line-height: 1.7;
}
.landing-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 40px;
}
.landing-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255,255,255,.06);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,.08);
    font-size: 14px;
    color: rgba(255,255,255,.85);
}
.landing-feature .icon { font-size: 20px; }

/* ====== ORDER FORM ====== */
.order-form-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    color: var(--text);
}
.order-form-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}
.order-form-card .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* File upload */
.file-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.file-drop:hover, .file-drop.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.file-drop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.file-list { margin-top: 8px; }
.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 13px;
    margin-top: 4px;
}
.file-item .remove { cursor: pointer; color: var(--danger); margin-left: auto; }

/* ====== AUTH LAYOUT ====== */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.auth-card .logo { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.auth-card .logo span { color: var(--primary); }
.auth-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }
.auth-card .form-group { text-align: left; }

/* ====== CLIENT LAYOUT ====== */
.client-layout {
    display: flex;
    min-height: 100vh;
}
.client-sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-light);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
}
.client-sidebar .logo {
    font-size: 22px;
    font-weight: 700;
    padding: 0 8px 24px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 16px;
}
.client-sidebar .logo span { color: var(--primary); }
.sidebar-nav { flex: 1; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}
.sidebar-link:hover { background: var(--bg); color: var(--text); }
.sidebar-link.active { background: var(--primary-light); color: var(--primary); }
.sidebar-link .count {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
}
.client-main {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    max-width: 1100px;
}
.page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
}

/* ====== ADMIN LAYOUT ====== */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 260px;
    background: var(--bg-dark);
    color: #fff;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
}
.admin-sidebar .logo {
    font-size: 22px;
    font-weight: 700;
    padding: 0 8px 24px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    margin-bottom: 16px;
}
.admin-sidebar .logo span { color: var(--primary); }
.admin-sidebar .sidebar-link {
    color: rgba(255,255,255,.6);
}
.admin-sidebar .sidebar-link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.admin-sidebar .sidebar-link.active {
    background: var(--primary);
    color: #fff;
}
.admin-main {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
}

/* ====== DASHBOARD ====== */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border-light);
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* Order mini card */
.order-mini {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    margin-bottom: 8px;
    transition: all var(--transition);
    cursor: pointer;
}
.order-mini:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.order-mini .order-id {
    font-weight: 700;
    font-size: 13px;
    color: var(--primary);
    min-width: 50px;
}
.order-mini .order-info { flex: 1; min-width: 0; }
.order-mini .order-info .name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.order-mini .order-info .meta {
    font-size: 12px;
    color: var(--text-muted);
}
.order-mini .order-right { text-align: right; }
.order-mini .order-right .amount {
    font-weight: 600;
    font-size: 14px;
}

/* ====== CHAT ====== */
.chat-wrap {
    display: flex;
    flex-direction: column;
    height: 400px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-msg {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}
.chat-msg.mine {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.theirs {
    align-self: flex-start;
    background: var(--bg);
    border-bottom-left-radius: 4px;
}
.chat-msg.internal {
    align-self: flex-start;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    font-style: italic;
}
.chat-msg .sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: .7;
}
.chat-msg .time {
    font-size: 11px;
    opacity: .5;
    margin-top: 4px;
    text-align: right;
}
.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-card);
}
.chat-input input[type="text"] {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}
.chat-input input[type="text"]:focus { border-color: var(--primary); }
.chat-input .btn { border-radius: 20px; }

/* ====== ORDER DETAIL ====== */
.order-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.order-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.meta-item { }
.meta-item .meta-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 4px;
}
.meta-item .meta-value {
    font-size: 15px;
    font-weight: 500;
}

/* Payment indicator */
.payment-bar {
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}
.payment-bar .fill {
    height: 100%;
    background: var(--success);
    border-radius: 3px;
    transition: width .5s ease;
}

/* ====== STICKY PAY ====== */
.sticky-pay {
    position: fixed;
    bottom: 0; left: 260px; right: 0;
    background: var(--bg-card);
    border-top: 2px solid var(--primary);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -4px 20px rgba(0,0,0,.1);
    z-index: 40;
}
.sticky-pay .pay-info .pay-label { font-size: 13px; color: var(--text-muted); }
.sticky-pay .pay-info .pay-amount { font-size: 22px; font-weight: 700; }

/* ====== FILTERS ====== */
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}
.filters .form-control { width: auto; min-width: 150px; padding: 8px 12px; font-size: 13px; }
.filters .search-input { min-width: 250px; }

/* ====== PAGINATION ====== */
.pagination {
    display: flex;
    gap: 4px;
    margin-top: 20px;
    justify-content: center;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ====== ALERTS ====== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* ====== MODAL ====== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform var(--transition);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
    transition: all var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }

/* ====== LOADING ====== */
.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== TOAST ====== */
.toast-container {
    position: fixed;
    top: 24px; right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    animation: slideIn .3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .landing-container { grid-template-columns: 1fr; gap: 32px; padding: 24px 16px; }
    .landing-features { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .client-sidebar, .admin-sidebar { display: none; }
    .client-main, .admin-main { margin-left: 0; padding: 16px; }
    .sticky-pay { left: 0; }
    .dash-grid { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .order-header { flex-direction: column; }
    .filters { flex-direction: column; }
    .filters .form-control, .filters .search-input { width: 100%; min-width: unset; }
}

/* ====== UTILS ====== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
