/* ============================================
   ليان - Component Styles
   ============================================ */

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    box-shadow: 0 6px 16px rgba(236, 72, 153, 0.35);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: var(--space-2) var(--space-3);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--text-primary);
    box-shadow: none;
    transform: none;
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
    border-radius: var(--border-radius-sm);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-base);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--border-radius-sm);
}

.btn-block {
    width: 100%;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--transition);
}

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

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

.card-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-color);
    background: var(--gray-50);
}

/* Stat Card */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    padding: var(--space-6);
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 3px;
}

.stat-card.pink::before {
    background: linear-gradient(90deg, var(--primary-400), var(--primary-600));
}

.stat-card.gold::before {
    background: linear-gradient(90deg, var(--gold-400), var(--gold-600));
}

.stat-card.green::before {
    background: linear-gradient(90deg, #34d399, #10b981);
}

.stat-card.purple::before {
    background: linear-gradient(90deg, #a78bfa, #7c3aed);
}

.stat-card.blue::before {
    background: linear-gradient(90deg, #60a5fa, #3b82f6);
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.pink {
    background: var(--primary-100);
    color: var(--primary-600);
}

.stat-icon.gold {
    background: var(--gold-100);
    color: var(--gold-600);
}

.stat-icon.green {
    background: var(--success-light);
    color: var(--success);
}

.stat-icon.purple {
    background: #ede9fe;
    color: #7c3aed;
}

.stat-icon.blue {
    background: #dbeafe;
    color: #3b82f6;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin-top: var(--space-1);
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: var(--space-5);
}

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--bg-card);
    transition: all var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 36px;
}

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

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
    font-weight: 500;
    user-select: none;
}

.checkbox-item:hover {
    border-color: var(--primary-300);
    background: var(--primary-50);
}

.checkbox-item.checked {
    border-color: var(--primary-500);
    background: var(--primary-50);
    color: var(--primary-700);
}

.checkbox-item input[type="checkbox"] {
    display: none;
}

.checkbox-mark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-300);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.checkbox-item.checked .checkbox-mark {
    background: var(--primary-500);
    border-color: var(--primary-500);
}

.checkbox-item.checked .checkbox-mark::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: 700;
}

/* ============================================
   Tables
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

thead {
    background: var(--gray-50);
}

th {
    padding: var(--space-3) var(--space-4);
    text-align: right;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tr:hover td {
    background: var(--gray-50);
}

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

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-3);
    border-radius: var(--border-radius-full);
    font-size: var(--font-size-xs);
    font-weight: 700;
    white-space: nowrap;
}

.badge-pink {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-green {
    background: var(--success-light);
    color: var(--success);
}

.badge-gold {
    background: var(--gold-100);
    color: var(--gold-600);
}

.badge-red {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-blue {
    background: var(--info-light);
    color: var(--info);
}

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state p {
    font-size: var(--font-size-sm);
    margin-top: var(--space-2);
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 2px solid var(--border-color);
    margin-bottom: var(--space-6);
    overflow-x: auto;
}

.tab {
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    font-family: var(--font-family);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-500);
}

/* ============================================
   Route Card (Visit Path)
   ============================================ */
.route-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

.route-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    position: relative;
    transition: background var(--transition-fast);
    border-radius: var(--border-radius);
}

.route-item:hover {
    background: var(--gray-50);
}

.route-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: var(--font-size-sm);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(236, 72, 153, 0.25);
}

.route-item:not(:last-child) .route-number::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 50%;
    transform: translateX(50%);
    width: 2px;
    height: calc(100% + 16px);
    background: var(--primary-200);
    z-index: 0;
}

.route-info {
    flex: 1;
    min-width: 0;
}

.route-info h4 {
    font-weight: 700;
    font-size: var(--font-size-base);
    margin-bottom: var(--space-1);
}

.route-info .route-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.route-debt {
    font-weight: 700;
    color: var(--danger);
    font-size: var(--font-size-sm);
}

.route-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* ============================================
   Section Header
   ============================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.section-header h2 {
    font-size: var(--font-size-2xl);
    font-weight: 800;
}

.section-header p {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* ============================================
   Grid Layouts
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-4);
}

/* ============================================
   Animations
   ============================================ */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-in {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-in-delay-1 {
    animation-delay: 0.05s;
    opacity: 0;
}

.animate-in-delay-2 {
    animation-delay: 0.1s;
    opacity: 0;
}

.animate-in-delay-3 {
    animation-delay: 0.15s;
    opacity: 0;
}

.animate-in-delay-4 {
    animation-delay: 0.2s;
    opacity: 0;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

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

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

    .tabs {
        gap: 0;
    }

    .tab {
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-size-xs);
    }

    .stat-card {
        padding: var(--space-4);
    }

    .stat-value {
        font-size: var(--font-size-xl);
    }
}