/* =============================================
   WorkBoard — Component Styles
   Buttons, Inputs, Cards, Badges, Modals, etc.
   ============================================= */

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    line-height: 1.5;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
    position: relative;
    overflow: hidden;
}

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

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: var(--text-on-primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

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

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

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

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

.btn-danger {
    background: var(--danger-500);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-600);
}

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

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

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

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
}

/* === FORM CONTROLS === */
.form-group {
    margin-bottom: var(--space-4);
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-base);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-input-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239794ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-right: var(--space-10);
}

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

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

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.quick-add-bar {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) auto;
    gap: var(--space-3);
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-sm);
}

.quick-add-bar .form-select,
.quick-add-bar .form-input {
    min-height: 40px;
}

@media (max-width: 720px) {
    .quick-add-bar {
        grid-template-columns: 1fr;
    }

    .quick-add-bar .btn {
        width: 100%;
    }
}

.form-error {
    font-size: var(--text-xs);
    color: var(--danger-500);
    margin-top: var(--space-1);
}

/* === CARDS === */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
}

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

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

.card-title {
    font-size: var(--text-md);
    font-weight: var(--font-semibold);
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-full);
    white-space: nowrap;
    line-height: 1.5;
}

.badge-priority-low {
    background: var(--priority-low-bg);
    color: var(--priority-low);
}

.badge-priority-medium {
    background: var(--priority-medium-bg);
    color: var(--priority-medium);
}

.badge-priority-high {
    background: var(--priority-high-bg);
    color: var(--priority-high);
}

.badge-priority-urgent {
    background: var(--priority-urgent-bg);
    color: var(--priority-urgent);
    animation: pulse 2s infinite;
}

.badge-status {
    padding: 2px 10px;
    font-size: var(--text-xs);
    border-radius: var(--radius-full);
}

.badge-todo {
    background: var(--info-50);
    color: var(--info-500);
}

.badge-in-progress {
    background: var(--warning-50);
    color: var(--warning-600);
}

.badge-done {
    background: var(--success-50);
    color: var(--success-600);
}

[data-theme="dark"] .badge-todo { background: rgba(59, 130, 246, 0.15); }
[data-theme="dark"] .badge-in-progress { background: rgba(245, 158, 11, 0.15); }
[data-theme="dark"] .badge-done { background: rgba(16, 185, 129, 0.15); }

/* === AVATAR === */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-weight: var(--font-bold);
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.avatar-xs {
    width: 24px;
    height: 24px;
    font-size: 9px;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 10px;
}

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

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

/* === MODAL === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-modal-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-8);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    overflow-y: auto;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: min(560px, calc(100vw - 32px));
    margin-top: var(--space-8);
    transform: translateY(20px) scale(0.97);
    transition: transform var(--transition-slow);
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

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

.modal-lg {
    max-width: min(760px, calc(100vw - 32px));
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    gap: var(--space-3);
    min-width: 0;
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    min-width: 0;
    overflow-wrap: anywhere;
}

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

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

.modal-body {
    padding: var(--space-6);
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-width: 0;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.modal * {
    min-width: 0;
}

@media (max-width: 520px) {
    .modal-overlay {
        padding: var(--space-3);
    }

    .modal {
        max-height: calc(100vh - 24px);
        margin-top: var(--space-2);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 440px;
    pointer-events: auto;
    animation: slideInRight var(--transition-slow) ease-out;
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.toast-close {
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color var(--transition-fast);
}

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

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

.toast-success .toast-icon {
    color: var(--success-500);
}

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

.toast-error .toast-icon {
    color: var(--danger-500);
}

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

.toast-info .toast-icon {
    color: var(--info-500);
}

/* === LOADING === */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-500);
    border-radius: var(--radius-full);
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-12);
}

/* === EMPTY STATE === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    color: var(--text-tertiary);
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--text-md);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-2);
}

.empty-state-description {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    max-width: 300px;
}

/* === DROPDOWN MENU === */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: var(--space-1);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: var(--space-1);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

.dropdown-menu.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

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

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

.dropdown-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-1) 0;
}

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

.tab {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

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

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

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

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