/* ============================================
   CENTRALIZED BUTTON SYSTEM
   ============================================
   
   All buttons across the application should use
   these standardized classes for consistency.
   
   DO NOT duplicate button styles in page-specific
   CSS files. Use these central definitions.
   ============================================ */

/* ============================================
   BASE BUTTON
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

/* ============================================
   BUTTON ICONS
   ============================================ */

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

/* ============================================
   BUTTON VARIANTS - Colors
   ============================================ */

/* Primary - Blue */
.btn-primary {
    background: var(--primary-color, #3b82f6);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

/* Secondary - Gray */
.btn-secondary {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-primary, #1f2937);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover, #e5e7eb);
}

/* Success - Green */
.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

/* Danger - Red */
.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Warning - Yellow/Orange */
.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
}

/* Info - Sky Blue */
.btn-info {
    background: #0ea5e9;
    color: white;
}

.btn-info:hover:not(:disabled) {
    background: #0284c7;
}

/* Outline Variants */
.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary-color, #3b82f6);
    color: var(--primary-color, #3b82f6);
}

.btn-outline-primary:hover:not(:disabled) {
    background: var(--primary-color, #3b82f6);
    color: white;
}

.btn-outline-secondary {
    background: transparent;
    border: 1px solid var(--text-secondary, #6b7280);
    color: var(--text-secondary, #6b7280);
}

.btn-outline-secondary:hover:not(:disabled) {
    background: var(--bg-secondary, #f3f4f6);
}

/* Ghost/Text Button */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary, #6b7280);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover, #f3f4f6);
}

/* ============================================
   BUTTON SIZES
   ============================================ */

/* Small */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    gap: 4px;
}

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

/* Large */
.btn-lg {
    padding: 10px 20px;
    font-size: 16px;
    gap: 8px;
}

.btn-lg .btn-icon {
    width: 18px;
    height: 18px;
}

/* Extra Large */
.btn-xl {
    padding: 12px 24px;
    font-size: 18px;
    gap: 8px;
}

.btn-xl .btn-icon {
    width: 20px;
    height: 20px;
}

/* ============================================
   BUTTON LAYOUT MODIFIERS
   ============================================ */

/* Full Width */
.btn-block {
    width: 100%;
    display: flex;
}

/* Icon Only (no text) */
.btn-icon-only {
    padding: 8px;
    gap: 0;
}

.btn-icon-only.btn-sm {
    padding: 6px;
}

.btn-icon-only.btn-lg {
    padding: 10px;
}

/* Square Button */
.btn-square {
    aspect-ratio: 1;
    padding: 8px;
}

.btn-square.btn-sm {
    padding: 6px;
}

.btn-square.btn-lg {
    padding: 10px;
}

/* ============================================
   ICON ACTION BUTTONS (Minimal, for tables/lists)
   ============================================ */

.btn-icon-action {
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s;
    color: var(--text-secondary, #6b7280);
}

.btn-icon-action:hover {
    background: var(--bg-hover, #e5e7eb);
    color: var(--text-primary, #1f2937);
}

.btn-icon-action.btn-danger {
    color: #dc2626;
}

.btn-icon-action.btn-danger:hover {
    background: #fee2e2;
    color: #991b1b;
}

.btn-icon-action svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   EXPAND/COLLAPSE BUTTON (for expandable rows)
   ============================================ */

.btn-expand {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.15s ease;
    color: var(--text-secondary, #6b7280);
    box-sizing: border-box;
}

.btn-expand:hover {
    background-color: var(--bg-secondary, #f3f4f6);
}

.btn-expand:active {
    background-color: var(--border-color, #e5e7eb);
}

.btn-expand svg {
    width: 24px;
    height: 24px;
    transition: transform 0.2s ease;
    display: block;
}

/* ============================================
   CLOSE BUTTON (for modals/dialogs)
   ============================================ */

.btn-close {
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s;
}

.btn-close:hover {
    background: var(--bg-hover, #e5e7eb);
}

.btn-close svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary, #6b7280);
}

/* ============================================
   TAB BUTTONS (for navigation tabs)
   ============================================ */

.btn-tab {
    background: transparent;
    color: var(--text-secondary, #6b7280);
    padding: 6px 12px;
    border-radius: 6px;
}

.btn-tab:hover {
    background: var(--bg-hover, #e5e7eb);
    color: var(--text-primary, #1f2937);
}

.btn-tab.active {
    background: var(--primary-color, #3b82f6);
    color: white;
}

.btn-tab .btn-icon {
    width: 16px;
    height: 16px;
}

/* ============================================
   BUTTON GROUPS
   ============================================ */

.btn-group {
    display: flex;
    gap: 8px;
}

.btn-group .btn {
    flex: 1;
}

.btn-group-sm {
    gap: 4px;
}

.btn-group-lg {
    gap: 12px;
}

/* Attached buttons (no gap) */
.btn-group-attached {
    gap: 0;
}

.btn-group-attached .btn:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.btn-group-attached .btn:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* ============================================
   LOADING STATE
   ============================================ */

.btn .spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

.btn-secondary .spinner-small,
.btn-ghost .spinner-small {
    border-color: rgba(0, 0, 0, 0.2);
    border-top-color: currentColor;
}

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

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    /* Make buttons slightly smaller on mobile */
    .btn {
        padding: 7px 14px;
        font-size: 13px;
    }

    .btn-lg {
        padding: 9px 18px;
        font-size: 15px;
    }

    /* Stack button groups on mobile */
    .btn-group-mobile-stack {
        flex-direction: column;
    }

    .btn-group-mobile-stack .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    /* Further reduce sizes on very small screens */
    .btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .btn-sm {
        padding: 5px 10px;
        font-size: 12px;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Remove button appearance (useful for custom styled buttons) */
.btn-unstyled {
    all: unset;
    cursor: pointer;
}

/* Justify content for buttons with icons */
.btn-justify-start {
    justify-content: flex-start;
}

.btn-justify-end {
    justify-content: flex-end;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .btn {
        display: none !important;
    }

    /* Show buttons explicitly marked for print */
    .btn-print {
        display: inline-flex !important;
    }
}
