/**
 * AUTOCORE360 Admin Panel - Buttons
 * Button variants, sizes, groups
 */

/* ============ BASE BUTTON ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    white-space: nowrap;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

/* Shine effect on hover - MANDIAG style */
.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    transition: left 0.75s ease;
}

.btn:hover::after {
    left: 100%;
}

.btn:hover {
    transform: var(--hover-lift-sm);
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 var(--ring-width) var(--ring-color);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    pointer-events: none;
    filter: grayscale(0.2);
}

.btn:disabled::after,
.btn.disabled::after {
    display: none;
}

/* ============ BUTTON VARIANTS ============ */

/* Primary Button */
.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 4px rgba(var(--primary-rgb, 37, 99, 235), 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 37, 99, 235), 0.4);
    color: white;
}

.btn-primary:active {
    box-shadow: 0 2px 4px rgba(var(--primary-rgb, 37, 99, 235), 0.3);
}

[data-theme="dark"] .btn-primary {
    box-shadow: 0 2px 4px rgba(var(--primary-rgb, 220, 38, 38), 0.3);
}

[data-theme="dark"] .btn-primary:hover {
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 220, 38, 38), 0.4);
}

/* Secondary Button */
.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    color: var(--text);
}

/* Success Button */
.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow);
}

.btn-success:hover {
    box-shadow: var(--shadow-success);
    filter: brightness(1.05);
    color: white;
}

/* Danger Button */
.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow);
}

.btn-danger:hover {
    box-shadow: var(--shadow-danger);
    filter: brightness(1.05);
    color: white;
}

/* Warning Button */
.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, var(--warning-dark) 100%);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow);
}

.btn-warning:hover {
    box-shadow: 0 4px 12px rgba(var(--warning-rgb, 245, 158, 11), 0.3);
    color: white;
}

/* Info Button */
.btn-info {
    background: linear-gradient(135deg, var(--info), var(--info-dark));
    color: white;
    border-color: var(--info);
}

.btn-info:hover {
    box-shadow: 0 4px 12px rgba(var(--info-rgb, 14, 165, 233), 0.3);
    color: white;
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: var(--text-light);
    border-color: transparent;
    box-shadow: none;
}

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

.btn-ghost:active {
    background: var(--surface-active);
}

/* Outline Button */
.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: none;
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-primary);
}

/* ============ BUTTON SIZES ============ */
.btn-xs {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    gap: 0.25rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    gap: 0.375rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    gap: 0.625rem;
}

.btn-xl {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-block {
    width: 100%;
}

/* ============ ICON BUTTONS ============ */
.btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: var(--radius);
}

.btn-icon.btn-circle {
    border-radius: 50%;
}

/* MANDIAG-style action icons */
.action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background-color: rgba(var(--primary-rgb, 37, 99, 235), 0.1);
    color: var(--primary);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-decoration: none;
    position: relative;
}

.action-icon:hover {
    background-color: var(--primary);
    color: white;
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 6px 12px rgba(var(--primary-rgb, 37, 99, 235), 0.2);
    text-decoration: none;
}

.action-icon:active {
    transform: translateY(-2px) scale(1.05);
}

/* CSS Tooltip for action icons with title attribute */
.action-icon[title] {
    position: relative;
}

.action-icon[title]::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: var(--surface-secondary);
    background-color: var(--text);
    color: var(--surface);
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm, 0.5rem);
    font-size: var(--text-xs, 0.75rem);
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: var(--z-tooltip, 1100);
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

.action-icon[title]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

/* Action icon variants */
.action-icon.success {
    background-color: rgba(var(--success-rgb, 34, 197, 94), 0.1);
    color: var(--success);
}

.action-icon.success:hover {
    background-color: var(--success);
    color: white;
    box-shadow: 0 6px 12px rgba(var(--success-rgb, 34, 197, 94), 0.2);
}

.action-icon.danger {
    background-color: rgba(var(--danger-rgb, 239, 68, 68), 0.1);
    color: var(--danger);
}

.action-icon.danger:hover {
    background-color: var(--danger);
    color: white;
    box-shadow: 0 6px 12px rgba(var(--danger-rgb, 239, 68, 68), 0.2);
}

.action-icon.warning {
    background-color: rgba(var(--warning-rgb, 245, 158, 11), 0.1);
    color: var(--warning);
}

.action-icon.warning:hover {
    background-color: var(--warning);
    color: white;
    box-shadow: 0 6px 12px rgba(var(--warning-rgb, 245, 158, 11), 0.2);
}

.action-icon.info {
    background-color: rgba(var(--info-rgb, 14, 165, 233), 0.1);
    color: var(--info);
}

.action-icon.info:hover {
    background-color: var(--info);
    color: white;
    box-shadow: 0 6px 12px rgba(var(--info-rgb, 14, 165, 233), 0.2);
}

/* Action icons container */
.action-icons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Dark mode adjustments */
[data-theme="dark"] .action-icon {
    background-color: rgba(220, 38, 38, 0.1);
    color: var(--primary);
}

[data-theme="dark"] .action-icon:hover {
    box-shadow: 0 6px 12px rgba(220, 38, 38, 0.3);
}

/* ============ BUTTON GROUPS ============ */
.btn-group {
    display: inline-flex;
    border-radius: var(--radius);
    overflow: hidden;
}

.btn-group .btn {
    border-radius: 0;
    margin: 0;
}

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

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

.btn-group .btn:not(:last-child) {
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-group-vertical {
    display: inline-flex;
    flex-direction: column;
    border-radius: var(--radius);
    overflow: hidden;
}

.btn-group-vertical .btn {
    border-radius: 0;
    margin: 0;
}

.btn-group-vertical .btn:first-child {
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

.btn-group-vertical .btn:last-child {
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.btn-group-vertical .btn:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* ============ LOADING STATE ============ */
.btn.loading {
    color: transparent;
    pointer-events: none;
}

.btn.loading::before {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btnSpinner 0.6s linear infinite;
}

.btn.loading::after {
    display: none;
}

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

/* Button with loading gets original color back for spinner */
.btn-primary.loading::before { border-color: white; border-right-color: transparent; }
.btn-success.loading::before { border-color: white; border-right-color: transparent; }
.btn-danger.loading::before { border-color: white; border-right-color: transparent; }
.btn-warning.loading::before { border-color: white; border-right-color: transparent; }
.btn-info.loading::before { border-color: white; border-right-color: transparent; }
.btn-secondary.loading::before { border-color: var(--text-muted); border-right-color: transparent; }

/* ============================================
   UI/UX AUDIT FIXES - January 2026
   ============================================ */

/* Issue #17: "Add Product" Button Text Wrapping - Already fixed with white-space: nowrap */

/* Mobile button adjustments */
@media (max-width: 480px) {
    /* Hide button text on very small screens, keep icon */
    .btn.btn-icon-mobile span,
    .page-header-actions .btn span.btn-text {
        display: none;
    }

    .btn.btn-icon-mobile i + span,
    .page-header-actions .btn i + span {
        display: none;
    }

    /* Ensure buttons don't get too small */
    .btn {
        min-width: 40px;
        min-height: 40px;
    }

    /* Full-width buttons in mobile header actions */
    .page-header-actions .btn:not(.btn-icon) {
        flex: 1;
        justify-content: center;
    }
}
