/* ===========================
   REUSABLE COMPONENTS
   =========================== */

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: all var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
    border: none;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--gradient-brand);
    color: #fff;
    box-shadow: 0 2px 12px rgba(0, 82, 204, 0.35);
}

.btn-primary:hover {
    filter: brightness(1.12);
    box-shadow: 0 4px 20px rgba(0, 82, 204, 0.5);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--brand-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.btn-success {
    background: var(--gradient-success);
    color: #fff;
}

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

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

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
    animation: fadeIn 0.3s ease both;
}

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

.card-glow {
    background: var(--gradient-card);
    border-color: rgba(0, 82, 204, 0.2);
    box-shadow: var(--shadow-glow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}

/* Debug: simulated clock — Daily Timesheet calendar card only */
.ts-sim-date-debug {
    margin: calc(-1 * var(--space-6)) calc(-1 * var(--space-6)) var(--space-5);
    padding: var(--space-4) var(--space-6);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--glass-border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.ts-sim-date-debug-hint {
    margin-top: 8px;
    font-size: 0.68rem;
    color: var(--text-muted);
    opacity: 0.9;
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* --- Stat Cards --- */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-brand);
}

.stat-card.accent-cyan::before {
    background: var(--gradient-cyan);
}

.stat-card.accent-success::before {
    background: var(--gradient-success);
}

.stat-card.accent-warning::before {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

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

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
    background: var(--bg-surface);
    border: 1.2px solid var(--bg-border);
    color: var(--text-secondary);
}

.stat-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.2;
}

.stat-icon.indigo { border-color: rgba(0, 82, 204, 0.2); color: var(--brand-primary); }
.stat-icon.cyan { border-color: rgba(6, 182, 212, 0.2); color: var(--brand-accent); }
.stat-icon.emerald { border-color: rgba(54, 179, 126, 0.2); color: var(--brand-success); }
.stat-icon.amber { border-color: rgba(255, 171, 0, 0.2); color: var(--brand-warning); }
.stat-icon.violet { border-color: rgba(139, 92, 246, 0.2); color: var(--brand-secondary); }
.stat-icon.red { border-color: rgba(255, 86, 48, 0.2); color: var(--brand-danger); }

.stat-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.stat-change {
    font-size: var(--text-xs);
    color: var(--brand-success);
    margin-top: var(--space-2);
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.negative {
    color: var(--brand-danger);
}

/* --- Badges / Status --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.badge-pending::before {
    background: #f59e0b;
}

.badge-approved {
    background: rgba(0, 82, 204, 0.12);
    color: #36b37e;
}

.badge-approved::before {
    background: #36b37e;
}

.badge-rejected {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.badge-rejected::before {
    background: #ef4444;
}

.badge-draft {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
}

.badge-draft::before {
    background: #64748b;
}

.badge-cancelled {
    background: rgba(100, 116, 139, 0.12);
    color: #64748b;
}

.badge-cancelled::before {
    background: #64748b;
}

/* --- Form Elements --- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

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

.form-label .required {
    color: var(--brand-danger);
    margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
    background: var(--bg-elevated);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-input[type="number"] {
    -moz-appearance: textfield;
}

.form-input[type="number"]::-webkit-outer-spin-button,
.form-input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

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

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

.form-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--brand-danger);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-4);
}

/* --- Table --- */
.table-wrapper {
    overflow-x: auto;
}

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

.table th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--bg-border);
    background: var(--bg-surface);
}

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

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

.table tr:hover td {
    background: var(--bg-hover);
}

.table td strong {
    color: var(--text-primary);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    animation: fadeIn 0.2s ease both;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease both;
}

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

.modal-title {
    font-size: var(--text-xl);
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

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

/* --- Tag Row --- */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--bg-border);
}

.tag.active {
    background: rgba(0, 82, 204, 0.12);
    color: var(--brand-primary);
    border-color: rgba(0, 82, 204, 0.25);
}

/* --- Timeline --- */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.timeline-item {
    display: flex;
    gap: var(--space-4);
    position: relative;
}

.timeline-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 32px;
    width: 2px;
    bottom: 0;
    background: var(--bg-border);
}

.timeline-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    z-index: 1;
}

.timeline-dot.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 2px solid rgba(245, 158, 11, 0.3);
}

.timeline-dot.approved {
    background: rgba(0, 82, 204, 0.15);
    color: #36b37e;
    border: 2px solid rgba(0, 82, 204, 0.3);
}

.timeline-dot.rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.timeline-dot.created {
    background: rgba(0, 82, 204, 0.15);
    color: #36b37e;
    border: 2px solid rgba(0, 82, 204, 0.3);
}

.timeline-content {
    flex: 1;
    padding-bottom: var(--space-6);
}

.timeline-title {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.timeline-time {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.timeline-note {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-2);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: var(--space-3);
}

/* --- Upload Zone --- */
.upload-zone {
    border: 2px dashed var(--bg-border);
    border-radius: var(--radius-md);
    padding: var(--space-8);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.upload-zone:hover {
    border-color: var(--brand-primary);
    background: rgba(0, 82, 204, 0.05);
}

.upload-zone.drag-over {
    border-color: var(--brand-primary);
    background: rgba(0, 82, 204, 0.08);
}

.upload-icon {
    font-size: 32px;
    margin-bottom: var(--space-3);
}

.upload-text {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

/* --- Progress Bar --- */
.progress-bar {
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    transition: width 0.6s ease;
}

.progress-fill.cyan {
    background: var(--gradient-cyan);
}

.progress-fill.success {
    background: var(--gradient-success);
}

.progress-fill.warning {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

/* --- Tooltip --- */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: var(--text-xs);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--bg-border);
}

.tooltip:hover::after {
    opacity: 1;
}

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

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

.empty-state h3 {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

/* --- Alert --- */
.alert {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.alert-success {
    background: rgba(0, 82, 204, 0.1);
    border: 1px solid rgba(0, 82, 204, 0.2);
    color: #36b37e;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.filter-bar--selects {
    gap: var(--space-5);
}

.filter-bar-field {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.filter-bar-field label {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-bar-field .form-select {
    min-width: 168px;
}

.filter-tabs {
    display: flex;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 2px;
}

.filter-tab {
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: transparent;
}

.filter-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.filter-tab:hover:not(.active) {
    color: var(--text-secondary);
}

/* --- Search Input --- */
.search-input-wrap {
    position: relative;
}

.search-input-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.search-input-wrap input {
    padding-left: 38px;
}

/* --- Avatar --- */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: var(--text-xs);
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: var(--text-lg);
}

/* --- Divider --- */
.divider {
    height: 1px;
    background: var(--bg-border);
    margin: var(--space-4) 0;
}

/* --- Toast --- */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease both;
    min-width: 240px;
}

.toast.success {
    border-left: 3px solid var(--brand-success);
}

.toast.error {
    border-left: 3px solid var(--brand-danger);
}

.toast.info {
    border-left: 3px solid var(--brand-info);
}

/* --- Dropdown --- */
.dropdown {
    position: relative;
    display: inline-flex;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    min-width: 160px;
    box-shadow: var(--shadow-md);
    z-index: 200;
    display: none;
    flex-direction: column;
    animation: scaleIn 0.15s ease both;
}

.dropdown.open .dropdown-menu {
    display: flex;
}

.dropdown-item {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-item.danger {
    color: var(--brand-danger);
}