/**
 * ============================================
 * UI Components - Clean Dashboard Style
 * ============================================
 * 
 * Matching reference: white cards, subtle borders,
 * progress bars, minimal design.
 * 
 * @package Botteraabox
 */

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 8px 16px;
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: white;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
}

.btn-ghost {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid transparent;
}

.btn-ghost:hover {
    background: var(--color-primary-bg);
    color: var(--color-primary-dark);
}

.btn-danger {
    background: var(--color-error);
    color: white;
    border-color: var(--color-error);
}

.btn-danger:hover {
    background: var(--color-error-dark);
}

.btn-sm {
    padding: 4px 12px;
    font-size: var(--text-xs);
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
}

/* ============================================
   Cards - Clean White
   ============================================ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: var(--space-4) var(--space-5);
}

.card-footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-color);
    background: var(--bg-hover);
}

/* ============================================
   Stat Card - With Icon Circle
   ============================================ */

.stat-card {
    padding: var(--space-4) var(--space-5);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

/* Mobile: smaller stat cards */
@media (max-width: 640px) {
    .stat-card {
        padding: var(--space-3);
        gap: var(--space-2);
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
    }

    .stat-card .stat-icon svg {
        width: 18px;
        height: 18px;
    }

    .stat-card .stat-value {
        font-size: var(--text-xl);
    }
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card .stat-icon svg {
    width: 22px;
    height: 22px;
    color: var(--text-muted);
}

.stat-card .stat-content {
    flex: 1;
    min-width: 0;
}

.stat-card .stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.stat-card .stat-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

/* ============================================
   Progress Card - With Bar
   ============================================ */

.progress-card {
    padding: var(--space-4) var(--space-5);
}

.progress-card .progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.progress-card .progress-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
}

.progress-card .progress-badge {
    padding: 2px 8px;
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--color-success-bg);
    color: var(--color-success);
}

.progress-card .progress-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: var(--space-1);
}

.progress-card .progress-sub {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-3);
}

.progress-card .progress-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.progress-card .progress-info span {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.progress-card .progress-percent {
    font-weight: 600;
    color: var(--text-primary);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.progress-fill.success {
    background: var(--color-success);
}

.progress-fill.info {
    background: var(--color-info);
}

.progress-fill.warning {
    background: var(--color-warning);
}

.progress-fill.primary {
    background: var(--color-primary);
}

/* ============================================
   Forms
   ============================================ */

.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    margin-bottom: var(--space-1);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.form-hint {
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ============================================
   Alerts
   ============================================ */

.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    margin-bottom: var(--space-3);
    border: 1px solid;
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border-color: var(--color-success);
}

.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error);
    border-color: var(--color-error);
}

.alert-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    border-color: var(--color-warning);
}

/* ============================================
   Badges
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-success {
    background: var(--color-success);
    color: white;
}

.badge-warning {
    background: var(--color-warning);
    color: white;
}

.badge-error {
    background: var(--color-error);
    color: white;
}

.badge-info {
    background: var(--color-info);
    color: white;
}

/* ============================================
   Avatar
   ============================================ */

.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--text-sm);
    color: white;
}

/* ============================================
   Table
   ============================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

/* Responsive Table */
@media (max-width: 768px) {
    .data-table {
        font-size: var(--text-sm);
    }

    .data-table th,
    .data-table td {
        padding: var(--space-2) var(--space-3);
    }

    /* Hide less important columns on mobile */
    .data-table .hide-mobile {
        display: none;
    }
}

@media (max-width: 480px) {

    .data-table th,
    .data-table td {
        padding: var(--space-2);
    }
}

/* ============================================
   Modal Dialog
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-4);
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-dialog {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 400px;
    width: 100%;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-body {
    padding: var(--space-4) var(--space-5);
}

.modal-body p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.modal-footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

/* ============================================
   List Item Cards
   ============================================ */

.list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-item-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: all 0.15s ease;
}

.list-item-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.list-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.list-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.list-item-avatar img {
    width: 40px;
    height: 40px;
    max-width: 40px;
    max-height: 40px;
    min-width: 40px;
    min-height: 40px;
    object-fit: cover;
    display: block;
    border-radius: 10px;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.list-item-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
}

.list-item-link {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    text-decoration: none;
    color: inherit;
}

.list-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.list-item-stats {
    display: flex;
    gap: 16px;
}

.list-item-badges {
    display: flex;
    gap: 6px;
}

/* ============================================
   Stat Chips
   ============================================ */

.stat-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.stat-chip.success {
    color: var(--color-success);
}

/* ============================================
   Status Badges
   ============================================ */

.status-badge {
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.status-badge.success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.status-badge.info {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.status-badge.muted {
    background: var(--bg-hover);
    color: var(--text-muted);
}

/* ============================================
   Bulk Toolbar
   ============================================ */

.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
}

.bulk-select-all {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.bulk-count {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.bulk-toolbar .btn-danger {
    margin-left: auto;
}

.item-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 4px;
}

.item-checkbox input[type="checkbox"],
.bulk-select-all input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ============================================
   Responsive List Grid
   ============================================ */

@media (min-width: 1200px) {
    .list-container.grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
}

@media (min-width: 900px) and (max-width: 1199px) {
    .list-container.grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}

@media (min-width: 640px) and (max-width: 899px) {
    .list-container.grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

@media (max-width: 639px) {
    .list-item-card {
        padding: 10px 12px;
    }

    .list-item-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .list-item-title {
        font-size: 14px;
    }

    .list-item-footer {
        margin-top: 10px;
        padding-top: 8px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .list-item-stats {
        gap: 12px;
    }

    .list-item-badges {
        flex-direction: row;
        gap: 4px;
    }
}

/* ============================================
   Card Header Link
   ============================================ */

.card-header-link {
    font-size: var(--text-sm);
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.card-header-link:hover {
    color: var(--color-primary-dark);
}

/* ============================================
   Activity List - Timeline Style
   ============================================ */

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.activity-item:first-child {
    padding-top: 0;
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.activity-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-time {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ============================================
   Request List - Avatar Cards
   ============================================ */

.request-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.request-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.request-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.request-item:first-child {
    padding-top: 0;
}

.request-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--text-xs);
    flex-shrink: 0;
    text-transform: uppercase;
}

.request-content {
    flex: 1;
    min-width: 0;
}

.request-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.request-channel {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Compact Badge Variant */
.badge-compact {
    padding: 3px 8px;
    font-size: 10px;
    gap: 3px;
}

/* ============================================
   3-Column Content Grid (Override layout.css)
   ============================================ */

.content-grid.content-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
}

.content-grid.content-grid-3>.col-4 {
    grid-column: span 1;
    min-width: 0;
}

/* Ensure cards stretch to equal height */
.content-grid.content-grid-3>.col-4>.card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.content-grid.content-grid-3>.col-4>.card>.card-body {
    flex: 1;
}

@media (max-width: 1200px) {
    .content-grid.content-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .content-grid.content-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Broadcast List - Dashboard
   ============================================ */

.broadcast-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.broadcast-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.broadcast-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.broadcast-item:first-child {
    padding-top: 0;
}

.broadcast-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--color-primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.broadcast-content {
    flex: 1;
    min-width: 0;
}

.broadcast-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.broadcast-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 1px;
}

/* ============================================
   Dashboard Cards - Balanced Heights
   ============================================ */

.content-grid.content-grid-3 .card-body {
    min-height: 200px;
    max-height: 280px;
    overflow-y: auto;
}

/* Custom scrollbar for card bodies */
.content-grid.content-grid-3 .card-body::-webkit-scrollbar {
    width: 4px;
}

.content-grid.content-grid-3 .card-body::-webkit-scrollbar-track {
    background: transparent;
}

.content-grid.content-grid-3 .card-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.content-grid.content-grid-3 .card-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}