/* ========================================
   Button System for A2GV2
   Theme-aware button styles
   ======================================== */

/* CSS Layer - Buttons are part of theme-components */
@layer theme-components {
    
    /* ========================================
       Base Button Styles
       ======================================== */
    
    .btn-theme {
        display: inline-block;
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
        font-weight: 500;
        line-height: 1.4;
        text-align: center;
        text-decoration: none;
        vertical-align: middle;
        cursor: pointer;
        border: 1px solid transparent;
        border-radius: var(--bs-border-radius);
        transition: all 0.15s ease-in-out;
        user-select: none;
    }
    
    /* ========================================
       Button Variants
       ======================================== */
    
    /* Primary button */
    .btn-theme-primary {
        background-color: var(--bs-primary);
        border-color: var(--bs-primary);
        color: var(--text-light);
    }
    
    .btn-theme-primary:hover {
        background-color: var(--primary-dark);
        border-color: var(--primary-dark);
        color: var(--text-light);
        box-shadow: var(--shadow-sm);
    }
    
    .btn-theme-primary:active,
    .btn-theme-primary.active {
        background-color: var(--primary-dark);
        border-color: var(--primary-dark);
        box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
    }
    
    .btn-theme-primary:focus {
        box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.5);
    }
    
    /* Secondary button */
    .btn-theme-secondary {
        background-color: var(--bs-secondary);
        border-color: var(--bs-secondary);
        color: var(--text-light);
    }
    
    .btn-theme-secondary:hover {
        background-color: var(--text-secondary);
        border-color: var(--text-secondary);
        color: var(--text-light);
        box-shadow: var(--shadow-sm);
    }
    
    .btn-theme-secondary:active,
    .btn-theme-secondary.active {
        background-color: var(--text-secondary);
        border-color: var(--text-secondary);
        box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
    }
    
    /* Success button */
    .btn-theme-success {
        background-color: var(--success-light);
        border-color: var(--success-light);
        color: var(--text-light);
    }
    
    .btn-theme-success:hover {
        filter: brightness(1.15);
        box-shadow: var(--shadow-sm);
    }
    
    /* Send/Confirm button - Uses Bootstrap primary for consistent send action styling */
    .btn-theme-send {
        background-color: #0d6efd;
        border-color: #0d6efd;
        color: #ffffff;
    }
    
    .btn-theme-send:hover {
        background-color: #0b5ed7;
        border-color: #0a58ca;
        color: #ffffff;
        box-shadow: var(--shadow-sm);
    }
    
    .btn-theme-send:active,
    .btn-theme-send.active {
        background-color: #0a58ca;
        border-color: #0a53be;
        box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
    }
    
    .btn-theme-send:focus {
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.5);
    }
    
    .btn-theme-send:disabled,
    .btn-theme-send.disabled {
        background-color: #0d6efd;
        border-color: #0d6efd;
        opacity: 0.65;
    }
    
    /* Danger button */
    .btn-theme-danger {
        background-color: var(--bs-danger);
        border-color: var(--bs-danger);
        color: var(--text-light);
    }
    
    .btn-theme-danger:hover {
        filter: brightness(0.85);
        box-shadow: var(--shadow-sm);
    }
    
    /* Warning button */
    .btn-theme-warning {
        background-color: var(--bs-warning);
        border-color: var(--bs-warning);
        color: var(--text-primary);
    }
    
    .btn-theme-warning:hover {
        filter: brightness(0.85);
        box-shadow: var(--shadow-sm);
    }
    
    /* Info button */
    .btn-theme-info {
        background-color: var(--bs-info);
        border-color: var(--bs-info);
        color: var(--text-light);
    }
    
    .btn-theme-info:hover {
        filter: brightness(0.85);
        box-shadow: var(--shadow-sm);
    }
    
    /* ========================================
       Outline Buttons
       ======================================== */
    
    .btn-theme-outline-primary {
        background-color: transparent;
        border-color: var(--bs-primary);
        color: var(--bs-primary);
    }
    
    .btn-theme-outline-primary:hover {
        background-color: var(--bs-primary);
        border-color: var(--bs-primary);
        color: var(--text-light);
        box-shadow: var(--shadow-sm);
    }
    
    .btn-theme-outline-secondary {
        background-color: transparent;
        border-color: var(--bs-secondary);
        color: var(--bs-secondary);
    }
    
    .btn-theme-outline-secondary:hover {
        background-color: var(--bs-secondary);
        border-color: var(--bs-secondary);
        color: var(--text-light);
        box-shadow: var(--shadow-sm);
    }
    
    /* ========================================
       Light & Dark Buttons
       ======================================== */
    
    .btn-theme-light {
        background-color: var(--bg-primary);
        border-color: var(--border-color);
        color: var(--text-primary);
    }
    
    .btn-theme-light:hover {
        background-color: var(--bg-tertiary);
        border-color: var(--border-color);
        color: var(--text-primary);
        box-shadow: var(--shadow-sm);
    }
    
    .btn-theme-dark {
        background-color: var(--bg-dark);
        border-color: var(--bg-dark);
        color: var(--text-light);
    }
    
    .btn-theme-dark:hover {
        background-color: var(--primary-dark);
        border-color: var(--primary-dark);
        color: var(--text-light);
        box-shadow: var(--shadow-sm);
    }
    
    /* ========================================
       Transparent Button
       ======================================== */
    
    .btn-theme-transparent {
        background-color: transparent;
        border-color: transparent;
        color: var(--text-primary);
    }
    
    .btn-theme-transparent:hover {
        background-color: rgba(0, 0, 0, 0.05);
        border-color: transparent;
        color: var(--text-primary);
        box-shadow: var(--shadow-sm);
    }
    
    .btn-theme-transparent:active,
    .btn-theme-transparent.active {
        background-color: rgba(0, 0, 0, 0.1);
        border-color: transparent;
        color: var(--text-primary);
        box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
    }
    
    .btn-theme-transparent:focus {
        background-color: transparent;
        color: var(--text-primary);
        box-shadow: none;
        outline: none;
    }
    
    .btn-theme-transparent:focus-visible {
        box-shadow: none;
        outline: none;
    }
    
    .btn-theme-transparent i {
        color: var(--text-primary);
    }
    
    /* Round variant for transparent button */
    .btn-theme-transparent.btn-theme-round {
        border-radius: 50% !important;
        padding: 0.5rem;
        width: 2.5rem;
        height: 2.5rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-theme-transparent.btn-theme-round i {
        font-size: 1.25rem;
        padding: 0;
        margin: 0;
        color: var(--text-primary);
    }
    
    .btn-theme-transparent.btn-theme-round:hover {
        background-color: rgba(0, 0, 0, 0.05);
    }
    
    .btn-theme-transparent.btn-theme-round:hover i {
        color: var(--text-primary);
        font-weight: 900; /* Trigger fill variant for Phosphor Icons */
    }
    
    .btn-theme-transparent.btn-theme-round:active,
    .btn-theme-transparent.btn-theme-round.active {
        background-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Size variants for round transparent buttons */
    .btn-theme-transparent.btn-theme-round.btn-theme-sm {
        padding: 0.35rem;
        width: 2rem;
        height: 2rem;
        border-radius: 50% !important;
    }
    
    .btn-theme-transparent.btn-theme-round.btn-theme-sm i {
        font-size: 1rem;
    }
    
    .btn-theme-transparent.btn-theme-round.btn-theme-lg {
        padding: 0.75rem;
        width: 3.5rem;
        height: 3.5rem;
        border-radius: 50% !important;
    }
    
    .btn-theme-transparent.btn-theme-round.btn-theme-lg i {
        font-size: 1.75rem;
    }
    
    /* ========================================
       Button Sizes
       ======================================== */
    
    .btn-theme-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
        border-radius: calc(var(--bs-border-radius) * 0.8);
    }
    
    .btn-theme-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1.125rem;
        border-radius: calc(var(--bs-border-radius) * 1.2);
    }
    
    /* ========================================
       Button States
       ======================================== */
    
    .btn-theme-block {
        display: block;
        width: 100%;
    }
    
    .btn-theme:disabled,
    .btn-theme.disabled {
        opacity: 0.65;
        cursor: not-allowed;
        pointer-events: none;
    }
    
    /* ========================================
       Button Groups
       ======================================== */
    
    .btn-theme-group {
        display: inline-flex;
        vertical-align: middle;
    }
    
    .btn-theme-group > .btn-theme:not(:last-child) {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        margin-right: -1px;
    }
    
    .btn-theme-group > .btn-theme:not(:first-child) {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
    }
    
    /* ========================================
       Icon Buttons
       ======================================== */
    
    .btn-icon {
        background: transparent;
        border: none;
        color: var(--text-header);
        cursor: pointer;
        padding: 0.2rem;
        font-size: 1.5rem;
        opacity: 0.7;
        transition: opacity 0.2s, transform 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 0.75rem;
    }
    
    .btn-icon i {
        font-size: 1.5rem;
        padding: 0;
        margin: 0;
    }
    
    .btn-icon:hover {
        opacity: 1;
        transform: scale(1.1);
    }
    
    .btn-icon:active {
        transform: scale(0.95);
    }
    
    .btn-icon:focus {
        outline: none;
        box-shadow: none;
    }
    
    .btn-icon:focus-visible {
        outline: none;
        box-shadow: none;
    }
    
    /* Icon button for delete/trash actions */
    .btn-icon.btn-icon-danger,
    .btn-icon .ph-trash {
        color: var(--bs-danger);
    }
    
    .btn-icon.btn-icon-danger i,
    .btn-icon:has(.ph-trash) {
        color: var(--bs-danger);
    }
    
    .btn-icon.btn-theme-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.9rem;
    }
    
    .btn-icon.btn-theme-sm i {
        font-size: 0.9rem;
    }
    
    .btn-icon.btn-theme-lg {
        padding: 0.5rem 0.75rem;
        font-size: 1.5rem;
    }
    
    .btn-icon.btn-theme-lg i {
        font-size: 1.5rem;
    }
    
    /* Legacy icon buttons - kept for backward compatibility */
    .btn-theme-icon {
        padding: 0.5rem;
        width: 2rem;
        height: 2rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-theme-icon.btn-theme-sm {
        width: 2rem;
        height: 2rem;
        padding: 0.25rem;
    }
    
    .btn-theme-icon.btn-theme-lg {
        width: 3rem;
        height: 3rem;
        padding: 0.75rem;
    }
    
    /* ========================================
       Link Button
       ======================================== */
    
    .btn-theme-link {
        background-color: transparent;
        border-color: transparent;
        color: var(--bs-primary);
        text-decoration: underline;
    }
    
    .btn-theme-link:hover {
        background-color: transparent;
        border-color: transparent;
        color: var(--primary-dark);
        text-decoration: underline;
        box-shadow: none;
    }
    
    /* ========================================
       Loading State
       ======================================== */
    
    .btn-theme-loading {
        position: relative;
        color: transparent !important;
        pointer-events: none;
    }
    
    .btn-theme-loading::after {
        content: "";
        position: absolute;
        width: 1rem;
        height: 1rem;
        top: 50%;
        left: 50%;
        margin-left: -0.5rem;
        margin-top: -0.5rem;
        border: 2px solid currentColor;
        border-radius: 50%;
        border-right-color: transparent;
        animation: btn-spinner 0.75s linear infinite;
    }
    
    @keyframes btn-spinner {
        to {
            transform: rotate(360deg);
        }
    }
}

/* ========================================
   Button Border Radius Overrides
   ======================================== */

button.btn-theme,
button.btn-theme-primary,
button.btn-theme-secondary,
button.btn-theme-success,
button.btn-theme-send,
button.btn-theme-danger,
button.btn-theme-warning,
button.btn-theme-info,
button.btn-theme-transparent {
    border-radius: var(--bs-border-radius) !important;
}
