/* ====================================================
   ProjectHub — Component Styles v2
   Forms, buttons, cards, tables, badges, avatars
   ==================================================== */

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

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

.btn .material-icons-outlined {
    font-size: 18px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-glow);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

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

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

.btn-danger {
    background: rgba(248, 113, 113, .12);
    color: var(--accent-red);
    border-color: transparent;
}

.btn-danger:hover {
    background: rgba(248, 113, 113, .22);
}

.btn-success {
    background: rgba(52, 211, 153, .12);
    color: var(--accent-green);
    border-color: transparent;
}

.btn-success:hover {
    background: rgba(52, 211, 153, .22);
}

.btn-sm {
    padding: 5px 12px;
    font-size: var(--font-xs);
    border-radius: var(--radius-sm);
}

.btn-secondary {
    background: var(--bg-surface-raised);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

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

.btn-lg {
    padding: 12px 28px;
    font-size: var(--font-base);
    border-radius: var(--radius-md);
}

.btn-block {
    width: 100%;
}

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

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

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

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

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

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

.form-select {
    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='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

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

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border);
}

.form-error {
    font-size: var(--font-xs);
    color: var(--accent-red);
    margin-top: 4px;
}

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

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    transition: all var(--transition-base);
}

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

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

.card-header h3 {
    font-size: var(--font-base);
    font-weight: 600;
}

/* ---------- Stat Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--stat-color, var(--primary)) 0%, transparent 60%);
    opacity: .06;
    transition: opacity var(--transition-base);
}

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

.stat-card:hover::before {
    opacity: .1;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    position: relative;
}

.stat-icon.blue {
    background: rgba(79, 140, 255, .12);
    color: var(--primary);
}

.stat-icon.green {
    background: rgba(52, 211, 153, .12);
    color: var(--accent-green);
}

.stat-icon.orange {
    background: rgba(251, 191, 36, .12);
    color: var(--accent-orange);
}

.stat-icon.purple {
    background: rgba(167, 139, 250, .12);
    color: var(--accent-purple);
}

.stat-icon.red {
    background: rgba(248, 113, 113, .12);
    color: var(--accent-red);
}

.stat-info {
    position: relative;
}

.stat-number {
    font-size: var(--font-2xl);
    font-weight: 800;
    line-height: 1.1;
}

.stat-label {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ---------- Data Tables ---------- */
.data-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.data-table thead th {
    text-align: left;
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-tertiary);
    background: var(--bg-surface-raised);
    border-bottom: 1px solid var(--border);
}

.data-table tbody td {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

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

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

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: var(--font-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
    line-height: 1.4;
}

.badge.green,
.badge-active,
.badge-done,
.badge-completed {
    background: rgba(52, 211, 153, .12);
    color: var(--accent-green);
}

.badge.blue,
.badge-in_progress,
.badge-planning {
    background: rgba(79, 140, 255, .12);
    color: var(--primary);
}

.badge.orange,
.badge-in_review,
.badge-on_hold,
.badge-medium {
    background: rgba(251, 191, 36, .12);
    color: var(--accent-orange);
}

.badge.red,
.badge-urgent,
.badge-cancelled {
    background: rgba(248, 113, 113, .12);
    color: var(--accent-red);
}

.badge.purple,
.badge-admin,
.badge-high {
    background: rgba(167, 139, 250, .12);
    color: var(--accent-purple);
}

.badge.gray,
.badge-todo,
.badge-low,
.badge-user {
    background: rgba(148, 163, 184, .12);
    color: var(--text-secondary);
}

/* ---------- Avatars ---------- */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-xs);
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

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

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

.avatar-xl {
    width: 72px;
    height: 72px;
    font-size: var(--font-xl);
}

.avatar-stack {
    display: flex;
}

.avatar-stack .avatar {
    margin-left: -8px;
    border: 2px solid var(--bg-card);
}

.avatar-stack .avatar:first-child {
    margin-left: 0;
}

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

.progress-bar-fill,
.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary), var(--accent-purple));
    transition: width var(--transition-slow);
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-xl);
}

.tab-btn,
.tab {
    padding: var(--space-md) var(--space-lg);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-tertiary);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

.tab-btn.active,
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

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

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

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

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

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xs);
    z-index: 300;
}

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

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

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

.dropdown-item.danger:hover {
    background: rgba(248, 113, 113, .1);
}

.dropdown-item .material-icons-outlined {
    font-size: 16px;
}

/* ---------- Search Input ---------- */
.search-input-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px var(--space-md);
    max-width: 320px;
    transition: all var(--transition-fast);
}

.search-input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-input-wrap input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: var(--font-sm);
    width: 100%;
}

.search-input-wrap input::placeholder {
    color: var(--text-tertiary);
}

.search-input-wrap .material-icons-outlined {
    font-size: 18px;
    color: var(--text-tertiary);
}

/* ---------- Checkbox ---------- */
.checkbox {
    width: 18px;
    height: 18px;
    appearance: none;
    border: 2px solid var(--border-strong);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    flex-shrink: 0;
}

.checkbox:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox:checked::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

/* ---------- Confirmation Dialog ---------- */
.confirm-dialog {
    text-align: center;
    padding: var(--space-lg) 0;
}

.confirm-dialog .material-icons-outlined {
    font-size: 48px;
    color: var(--accent-red);
    margin-bottom: var(--space-md);
}

.confirm-dialog p {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

.confirm-dialog .btn-group {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
}