@import 'tailwindcss';

@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
@source '../../storage/framework/views/*.php';
@source '../**/*.blade.php';
@source '../**/*.js';

@theme {
    --font-sans: 'Inter', 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
}

/* =============================================
   ORDINA — Design System
   ============================================= */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --primary-muted: #818cf8;

    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active-bg: rgba(99, 102, 241, 0.15);
    --sidebar-active-border: #6366f1;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #e2e8f0;
    --sidebar-width: 240px;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;

    --text: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --success: #10b981;
    --success-bg: #d1fae5;
    --success-border: #6ee7b7;
    --success-text: #065f46;

    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --danger-border: #fca5a5;
    --danger-text: #991b1b;

    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --warning-border: #fcd34d;
    --warning-text: #92400e;

    --info: #3b82f6;
    --info-bg: #dbeafe;
    --info-border: #93c5fd;

    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.05);
    --shadow: 0 1px 3px 0 rgba(0,0,0,.1), 0 1px 2px -1px rgba(0,0,0,.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);

    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }

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

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    text-decoration: none;
}

.sidebar-logo img {
    height: 36px;
    width: auto;
    border-radius: 6px;
    object-fit: contain;
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
}

.sidebar-logo-name {
    color: #f1f5f9;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.sidebar-logo-sub {
    color: var(--sidebar-text);
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

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

.sidebar-section-label {
    color: var(--text-light);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 12px 20px 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-text);
    padding: 9px 20px;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
    position: relative;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    text-decoration: none;
}

.sidebar-nav a.active,
.sidebar-nav a[aria-current="page"] {
    background: var(--sidebar-active-bg);
    color: #a5b4fc;
    border-left-color: var(--sidebar-active-border);
}

.sidebar-nav a .nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav a:hover .nav-icon,
.sidebar-nav a.active .nav-icon {
    opacity: 1;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,.06);
    margin: 8px 0;
}

.badge-update {
    background: var(--danger);
    color: white;
    border-radius: var(--radius-full);
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
}

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

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

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-name {
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

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

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

/* ===== TOP HEADER ===== */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}

.topbar-hamburger:hover { background: var(--bg); color: var(--text); }

.topbar-page-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== CONTENT AREA ===== */
.main-content {
    flex: 1;
    padding: 28px 28px 40px;
}

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

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.actions-bar h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.card:hover { box-shadow: var(--shadow); }

.card h3 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== KPI CARDS ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-muted));
}

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1;
    margin-bottom: 4px;
}

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

.kpi-icon {
    position: absolute;
    top: 16px; right: 16px;
    width: 36px; height: 36px;
    border-radius: var(--radius);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

/* ===== AI WIDGET ===== */
.ai-widget {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e293b 100%);
    border: 1px solid rgba(99,102,241,.3);
    border-radius: var(--radius-xl);
    padding: 24px;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}

.ai-widget::before {
    content: '';
    position: absolute;
    top: -30%; right: -10%;
    width: 300px; height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,.2) 0%, transparent 70%);
    pointer-events: none;
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(99,102,241,.25);
    border: 1px solid rgba(99,102,241,.4);
    color: #a5b4fc;
    border-radius: var(--radius-full);
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.ai-badge-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #6366f1;
    box-shadow: 0 0 6px #6366f1;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ai-title {
    color: #f1f5f9;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.ai-subtitle {
    color: #94a3b8;
    font-size: 13px;
}

.ai-input-area {
    position: relative;
}

.ai-textarea {
    width: 100%;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--radius-lg);
    color: #f1f5f9;
    font-size: 14px;
    padding: 14px 16px;
    resize: none;
    font-family: inherit;
    line-height: 1.6;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.ai-textarea::placeholder { color: #64748b; }
.ai-textarea:focus {
    outline: none;
    border-color: rgba(99,102,241,.6);
    background: rgba(255,255,255,.1);
}

.ai-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(99,102,241,.4);
}

.ai-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99,102,241,.5);
}

.ai-submit-btn:active { transform: translateY(0); }

/* ===== AI CONFIRMATION BOX ===== */
.ai-confirm-box {
    margin-top: 20px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.ai-confirm-box label {
    display: block;
    color: #a5b4fc;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.ai-confirm-box select {
    width: 100%;
    max-width: 520px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    color: #f1f5f9;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 14px;
    appearance: none;
}

.ai-confirm-box select:focus {
    outline: none;
    border-color: rgba(99,102,241,.6);
}

.ai-confirm-box pre {
    background: rgba(0,0,0,.3);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    color: #94a3b8;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    margin: 8px 0 16px;
}

.ai-info-row {
    background: rgba(99,102,241,.12);
    border: 1px solid rgba(99,102,241,.2);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: #a5b4fc;
    font-size: 13px;
    margin-bottom: 14px;
}

.ai-confirm-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-confirm-btn:hover { background: #059669; }

/* ===== GRID LAYOUT ===== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

/* ===== TABLES ===== */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

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

.table-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

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

table th {
    background: #f8fafc;
    padding: 11px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

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

table tbody tr:hover { background: var(--surface-hover); }

.right, .text-right { text-align: right; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

.badge-gray {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid #c7d2fe;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none !important;
    transition: all 0.15s ease;
    line-height: 1.4;
    white-space: nowrap;
}

.btn:hover { text-decoration: none !important; }

.btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 1px 3px rgba(99,102,241,.3);
}

.btn.primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 3px 8px rgba(99,102,241,.4);
    transform: translateY(-1px);
}

.btn.secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-dark);
}

.btn.secondary:hover {
    background: var(--bg);
    border-color: #94a3b8;
}

.btn.danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn.danger:hover {
    background: #dc2626;
    box-shadow: 0 3px 8px rgba(239,68,68,.3);
    transform: translateY(-1px);
}

.btn.success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn.success:hover { background: #059669; }

.btn.link {
    background: transparent;
    color: var(--primary);
    border-color: transparent;
    padding: 8px 4px;
}

.btn.link:hover {
    color: var(--primary-dark);
    text-decoration: underline !important;
}

.btn.sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ===== FORMS ===== */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    max-width: 680px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.form-group .hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: -2px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

textarea { resize: vertical; }

select { appearance: none; cursor: pointer; }

/* ===== ALERTS ===== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    font-size: 14px;
    border: 1px solid transparent;
}

.alert.success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}

.alert.error {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.alert.warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

/* ===== OVERLAY (mobile sidebar) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

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

.empty-state p {
    font-size: 15px;
    margin: 0;
}

/* ===== SECTION TITLE ===== */
.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 28px 0 16px;
    letter-spacing: -0.2px;
}

/* ===== QUICK ACTIONS CARD ===== */
.quick-actions-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.quick-actions-card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.quick-action-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    text-decoration: none !important;
    transition: color 0.15s;
}

.quick-action-link:last-child { border-bottom: none; }

.quick-action-link:hover { color: var(--primary); text-decoration: none !important; }

.quick-action-icon {
    width: 30px; height: 30px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

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

    .main-wrapper {
        margin-left: 0;
    }

    .topbar-hamburger {
        display: flex;
    }

    .main-content {
        padding: 16px;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .actions-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .ai-widget {
        padding: 18px;
    }
}
