/* components.css - Reusable UI components */

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

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

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

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

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

.btn-icon {
    padding: var(--space-2);
    line-height: 0;
}

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

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

/* ===== Inputs ===== */
.input,
.textarea,
.select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: inherit;
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast);
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: var(--accent);
}

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

.textarea {
    min-height: 100px;
    resize: vertical;
    line-height: var(--line-height);
}

.select {
    cursor: pointer;
    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='%238a8f98' 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;
    padding-right: 36px;
}

.input-sm,
.textarea-sm,
.select-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

/* Form field wrapper */
.form-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

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

.form-field .required {
    color: var(--error);
    margin-left: var(--space-1);
}

.form-field .field-description {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* ===== Cards ===== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.card-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
}

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

.card-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--border);
}

.card-interactive {
    cursor: pointer;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.card-interactive:hover {
    border-color: var(--accent);
    transform: translateX(4px);
}

/* ===== Messages ===== */
.message {
    padding: var(--space-3);
    border-radius: var(--radius);
    font-size: var(--text-sm);
}

.message-success {
    background: var(--success-muted);
    color: var(--success);
}

.message-error {
    background: var(--error-muted);
    color: var(--error);
}

.message-warning {
    background: var(--warning-muted);
    color: var(--warning);
}

.message-info {
    background: var(--accent-muted);
    color: var(--accent);
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-accent {
    background: var(--accent-muted);
    color: var(--accent);
}

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

.badge-error {
    background: var(--error-muted);
    color: var(--error);
}

/* ===== Dropdown ===== */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    z-index: 100;
    min-width: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

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

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

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

/* ===== Spinner ===== */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.spinner-sm { width: 12px; height: 12px; border-width: 1.5px; }
.spinner-lg { width: 24px; height: 24px; border-width: 3px; }

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

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

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

/* ===== Attachment Chip ===== */
.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
}

.attachment-chip.image {
    padding: var(--space-1);
    padding-right: var(--space-2);
}

.attachment-chip img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: var(--radius);
}

.attachment-chip .attachment-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-chip .remove-attachment {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-1);
    line-height: 0;
    transition: color var(--transition-fast);
}

.attachment-chip .remove-attachment:hover {
    color: var(--error);
}

/* ===== Pulse Animation ===== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}
