/* ============================================================
   TokensCloud — Components
   ============================================================ */

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-7);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    font-family: var(--font-family);
    line-height: var(--line-height-tight);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }
.btn:disabled, .btn.disabled { opacity: 0.6; cursor: not-allowed; }

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

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

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

.btn-secondary { background: var(--gray-200); color: var(--gray-700); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--gray-300); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #218838; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c82333; }

.btn-warning { background: var(--warning); color: var(--gray-900); }
.btn-warning:hover { background: #e0a800; }

.btn-outline-primary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: white; }

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

.form-label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--gray-700);
    margin-bottom: var(--space-2);
    display: block;
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-md);
    font-family: var(--font-family);
    border: 1px solid var(--gray-400);
    border-radius: var(--border-radius);
    background: var(--bg-input);
    color: var(--text-primary);
    transition: all var(--transition-normal);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

.form-control:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

.form-control.is-invalid {
    border-color: var(--danger);
}

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

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 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.form-text {
    font-size: var(--font-size-sm);
    color: var(--gray-600);
    margin-top: var(--space-2);
}

.form-error {
    font-size: var(--font-size-sm);
    color: var(--danger);
    margin-top: var(--space-2);
}

.form-row {
    display: flex;
    gap: var(--space-5);
}

.form-row > .form-group {
    flex: 1;
}

/* Compact forms */
.form-compact .form-group { margin-bottom: var(--space-3); }
.form-compact .form-label { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.3px; }
.form-compact .form-control { padding: 6px 8px; }

/* ----- Cards ----- */
.card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-sm);
    overflow: hidden;
    margin-bottom: var(--space-5);
}

.card-header {
    padding: var(--space-4) var(--space-6);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    color: var(--gray-900);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

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

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

/* ----- Badges ----- */
.badge {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--border-radius);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    white-space: nowrap;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning-text); }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }
.badge-info { background: var(--info-light); color: var(--info); }

/* ----- KPI Cards ----- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-7);
}

.kpi-card {
    background: var(--bg-white);
    padding: var(--space-5) var(--space-7);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-sm);
}

.kpi-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-semibold);
    color: var(--gray-900);
    line-height: 1.2;
}

.kpi-label {
    font-size: var(--font-size-sm);
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: var(--space-1);
}

/* ----- Alerts ----- */
.alert {
    padding: var(--space-5) var(--space-7);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-7);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    font-size: var(--font-size-md);
}

.alert-success { background: var(--success-light); border: 1px solid var(--success); color: var(--success-text); }
.alert-danger { background: var(--danger-light); border: 1px solid var(--danger); color: var(--danger-text); }
.alert-warning { background: var(--warning-light); border: 1px solid var(--warning); color: var(--warning-text); }
.alert-info { background: var(--info-light); border: 1px solid var(--info); color: var(--info-text); }

.alert-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.5;
    color: inherit;
}
.alert-close:hover { opacity: 1; }

/* ----- Filters Section ----- */
.filters-section {
    background: var(--bg-white);
    padding: var(--space-7);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-sm);
    margin-bottom: var(--space-7);
}

.filters-row {
    display: flex;
    gap: var(--space-5);
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: var(--space-2);
}

.filter-group .form-control {
    min-width: 150px;
}

.filter-group .form-control[type="search"],
.filter-group .form-control[type="text"].search-input {
    min-width: 250px;
}

/* Quick filter buttons */
.quick-filters {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-7);
    flex-wrap: wrap;
}

/* ----- Modals ----- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-backdrop);
}

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

.modal-container {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-xl);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.2s ease;
}

.modal-lg { max-width: 800px; }

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

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

.modal-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-500);
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--gray-800); }

.modal-body {
    padding: var(--space-5);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* ----- Info Rows (key-value) ----- */
.info-row {
    display: flex;
    gap: var(--space-5);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--gray-200);
}

.info-label {
    flex: 0 0 140px;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--gray-600);
}

.info-value {
    flex: 1;
    color: var(--gray-800);
    font-size: var(--font-size-md);
}

.info-grid-compact .info-row {
    gap: var(--space-3);
    padding: var(--space-2) 0;
}

.info-grid-compact .info-label {
    flex: 0 0 100px;
}

/* ----- Timeline ----- */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-300);
}

.timeline-item {
    position: relative;
    padding-bottom: var(--space-5);
}

.timeline-dot {
    position: absolute;
    left: -24px;
    top: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gray-300);
    border: 2px solid var(--bg-white);
}

.timeline-dot.dot-success { background: var(--success); }
.timeline-dot.dot-danger { background: var(--danger); }
.timeline-dot.dot-warning { background: var(--warning); }
.timeline-dot.dot-info { background: var(--info); }
.timeline-dot.dot-primary { background: var(--primary); }

.timeline-content {
    font-size: var(--font-size-sm);
    color: var(--gray-800);
}

.timeline-meta {
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    margin-top: var(--space-1);
}

/* ----- Tabs ----- */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-300);
    margin-bottom: var(--space-7);
}

.tab {
    padding: var(--space-4) var(--space-7);
    color: var(--gray-600);
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-md);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab:hover { color: var(--gray-900); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ----- Spinner ----- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.spinner-lg { width: 32px; height: 32px; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ----- Empty State ----- */
.empty-state {
    padding: 40px;
    text-align: center;
}

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

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--gray-800);
    margin-bottom: var(--space-3);
}

.empty-state-text {
    color: var(--gray-600);
    margin-bottom: var(--space-7);
}

/* ----- Tooltips (CSS-only) ----- */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    font-size: var(--font-size-xs);
    border-radius: var(--border-radius);
    padding: var(--space-2) var(--space-3);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: var(--z-tooltip);
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ----- Notification Badge ----- */
.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: var(--font-weight-semibold);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ----- Progress Bar (for effective time) ----- */
.progress-bar {
    display: flex;
    height: 20px;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--gray-200);
}

.progress-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: var(--font-weight-semibold);
    color: white;
    white-space: nowrap;
    overflow: hidden;
}

.progress-active { background: var(--success); }
.progress-paused { background: var(--gray-400); background-image: repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(255,255,255,0.2) 3px, rgba(255,255,255,0.2) 6px); }
.progress-remaining { background: var(--primary); }
.progress-remaining.urgent { background: var(--warning); }
.progress-remaining.critical { background: var(--danger); }

/* ----- Autocomplete Dropdown ----- */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    z-index: var(--z-dropdown);
    display: none;
}

.autocomplete-dropdown.active { display: block; }

.autocomplete-item {
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--bg-secondary);
}

.autocomplete-item-title {
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-md);
}

.autocomplete-item-subtitle {
    font-size: var(--font-size-xs);
    color: var(--gray-500);
}

/* ----- Bulk Action Bar ----- */
.bulk-action-bar {
    position: fixed;
    bottom: 0;
    left: 240px;
    right: 0;
    background: var(--gray-900);
    color: white;
    padding: var(--space-4) var(--space-7);
    display: none;
    align-items: center;
    justify-content: space-between;
    z-index: var(--z-fixed);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
}

.bulk-action-bar.active { display: flex; }

.bulk-action-bar .btn {
    color: white;
    border-color: rgba(255,255,255,0.3);
}
