/*
 * ═══════════════════════════════════════════════════════
 *  COMPONENTS — Buttons, Cards, Badges, Forms, Modals
 * ═══════════════════════════════════════════════════════
 */

/* ─── Buttons ────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-5);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-brand-dark), var(--color-brand));
    color: white;
    box-shadow: var(--shadow-sm), 0 0 12px var(--color-brand-glow);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-brand), var(--color-brand-light));
    box-shadow: var(--shadow-md), 0 0 20px var(--color-brand-glow);
    color: white;
}

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

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}
.btn-ghost:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

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

.btn-success {
    background: var(--color-success);
    color: var(--color-text-inverse);
}
.btn-success:hover {
    background: #10b981;
    color: var(--color-text-inverse);
}

.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-icon {
    padding: var(--space-2);
    line-height: 1;
}

.btn-group {
    display: flex;
    gap: var(--space-2);
}

/* ─── Cards ──────────────────────────────────────────── */
.card {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--color-border-hover);
}

.card-glass {
    background: var(--color-bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.card-interactive {
    cursor: pointer;
}
.card-interactive:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

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

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

.card-stat {
    text-align: center;
    padding: var(--space-5);
}

.card-stat .stat-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--color-brand);
    line-height: 1.2;
}

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

/* ─── Alert Cards (overdue, due soon) ────────────────── */
.alert-card {
    border-left: 4px solid;
    padding: var(--space-4) var(--space-5);
}

.alert-card-danger {
    border-left-color: var(--color-error);
    background: rgba(248, 113, 113, 0.08);
}

.alert-card-warning {
    border-left-color: var(--color-warning);
    background: rgba(251, 191, 36, 0.08);
}

.alert-card-success {
    border-left-color: var(--color-success);
    background: rgba(52, 211, 153, 0.08);
}

.alert-card-info {
    border-left-color: var(--color-info);
    background: rgba(96, 165, 250, 0.08);
}

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

.badge-new        { background: rgba(129, 140, 248, 0.15); color: var(--color-status-new); }
.badge-progress   { background: rgba(96, 165, 250, 0.15);  color: var(--color-status-progress); }
.badge-waiting    { background: rgba(251, 191, 36, 0.15);   color: var(--color-status-waiting); }
.badge-resolved   { background: rgba(52, 211, 153, 0.15);   color: var(--color-status-resolved); }
.badge-closed     { background: rgba(100, 116, 139, 0.15);  color: var(--color-status-closed); }

.priority-low     { background: rgba(148, 163, 184, 0.15); color: var(--color-priority-low); }
.priority-medium  { background: rgba(96, 165, 250, 0.15);  color: var(--color-priority-medium); }
.priority-high    { background: rgba(251, 146, 60, 0.15);  color: var(--color-priority-high); }
.priority-urgent  { background: rgba(248, 113, 113, 0.15); color: var(--color-priority-urgent); }

.badge-category {
    padding: 2px var(--space-2);
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
    font-weight: 500;
    text-transform: none;
}

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

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

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

.form-control:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px var(--color-brand-glow);
    background: var(--color-bg-primary);
}

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

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

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

.form-hint {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    margin-top: var(--space-1);
}

/* ─── Quick Log Textarea ─────────────────────────────── */
.quicklog-input {
    width: 100%;
    min-height: 120px;
    padding: var(--space-5);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.7;
    color: var(--color-text-primary);
    background: var(--color-bg-secondary);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    resize: vertical;
    transition: all var(--transition-fast);
    outline: none;
}

.quicklog-input:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 4px var(--color-brand-glow), var(--shadow-glow);
    background: var(--color-bg-primary);
}

.quicklog-input::placeholder {
    color: var(--color-text-tertiary);
    font-style: italic;
}

/* ─── Tables ─────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

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

.data-table thead {
    background: var(--color-bg-secondary);
}

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

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

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--color-bg-secondary);
}

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

/* ─── Flash Messages ─────────────────────────────────── */
.flash-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 400px;
}

.flash {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: flashSlideIn 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.flash-success {
    background: rgba(52, 211, 153, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: var(--color-success);
}

.flash-error {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--color-error);
}

.flash-warning {
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: var(--color-warning);
}

.flash-info {
    background: rgba(96, 165, 250, 0.15);
    border: 1px solid rgba(96, 165, 250, 0.3);
    color: var(--color-info);
}

@keyframes flashSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

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

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

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

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

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

/* ─── Photo Upload ───────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--color-text-tertiary);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--color-brand);
    background: var(--color-brand-glow);
    color: var(--color-brand);
}

.upload-zone input[type="file"] {
    display: none;
}

.upload-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.upload-preview .preview-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--color-bg-secondary);
}

.upload-preview .preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-preview .preview-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* ─── Camera Capture Button ──────────────────────────── */
.btn-camera {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.btn-camera:hover {
    background: linear-gradient(135deg, #0d9488, #0f766e);
    box-shadow: 0 0 16px rgba(20, 184, 166, 0.3);
}

/* ─── Modal ──────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

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

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

.modal-close:hover {
    background: var(--color-error);
    color: white;
}

/* ─── Tooltip ────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    margin-bottom: 4px;
}

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

/* ─── Skeleton Loading ───────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--color-bg-secondary) 25%, var(--color-bg-tertiary) 50%, var(--color-bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
