/* ===== Buttons - Unified System ===== */
/* ملف الأزرار الموحد - مطابق للتنسيقات الحالية */

/* ===== Base Button Styles ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.5rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    vertical-align: middle;
    white-space: nowrap;
    
    /* Prevent button from shrinking */
    flex-shrink: 0;
    
    /* Focus styles */
    &:focus {
        outline: 2px solid var(--primary);
        outline-offset: 2px;
    }
    
    /* Disabled styles */
    &:disabled,
    &.disabled {
        opacity: 0.6;
        cursor: not-allowed;
        pointer-events: none;
    }
}

/* ===== Primary Button ===== */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--light);
    
    &:hover:not(:disabled) {
        background-color: var(--button-primary-hover);
        border-color: var(--button-primary-hover);
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }
    
    &:active {
        transform: translateY(0);
        box-shadow: var(--shadow-sm);
    }
}

/* ===== Secondary Button ===== */
.btn-secondary {
    background-color: var(--button-secondary);
    border-color: var(--border-light);
    color: var(--text-primary);
    
    &:hover:not(:disabled) {
        background-color: var(--button-secondary-hover);
        border-color: var(--border-medium);
        transform: translateY(-1px);
        box-shadow: var(--shadow-sm);
    }
}

/* ===== Outline Buttons ===== */
.btn-outline-primary {
    background-color: transparent;
    border-color: var(--primary);
    color: var(--primary);
    
    &:hover:not(:disabled) {
        background-color: var(--primary);
        color: var(--text-white);
    }
}

.btn-outline-secondary {
    background-color: transparent;
    border-color: var(--border-medium);
    color: var(--text-secondary);
    
    &:hover:not(:disabled) {
        background-color: var(--secondary-dark);
        border-color: var(--border-medium);
    }
}

/* ===== Ghost Buttons ===== */
.btn-ghost {
    background-color: transparent;
    border-color: transparent;
    color: var(--primary);
    
    &:hover:not(:disabled) {
        background-color: var(--primary-light);
        color: var(--primary-dark);
    }
}

/* ===== Status Buttons ===== */
.btn-success {
    background-color: var(--success);
    border-color: var(--success);
    color: var(--text-white);
    
    &:hover:not(:disabled) {
        background-color: #218838;
        border-color: #1e7e34;
    }
}

.btn-danger {
    background-color: var(--error);
    border-color: var(--error);
    color: var(--text-white);
    
    &:hover:not(:disabled) {
        background-color: #c82333;
        border-color: #bd2130;
    }
}

.btn-warning {
    background-color: var(--warning);
    border-color: var(--warning);
    color: var(--text-primary);
    
    &:hover:not(:disabled) {
        background-color: #e0a800;
        border-color: #d39e00;
    }
}

.btn-info {
    background-color: var(--info);
    border-color: var(--info);
    color: var(--text-white);
    
    &:hover:not(:disabled) {
        background-color: #138496;
        border-color: #117a8b;
    }
}

/* ===== Button Sizes ===== */
.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: var(--font-size-small);
    border-radius: var(--border-radius-sm);
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: var(--font-size-large);
    border-radius: var(--border-radius-md);
}

.btn-xl {
    padding: var(--spacing-lg) var(--spacing-2xl);
    font-size: var(--font-size-xl);
    border-radius: var(--border-radius-lg);
}

/* ===== Special Button Styles ===== */
.btn-rounded {
    border-radius: var(--border-radius-full);
}

.btn-square {
    border-radius: 0;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-icon-only {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    
    &.btn-sm {
        width: 2rem;
        height: 2rem;
    }
    
    &.btn-lg {
        width: 3rem;
        height: 3rem;
    }
}

/* ===== Button Groups ===== */
.btn-group {
    display: inline-flex;
    vertical-align: middle;
    
    .btn {
        border-radius: 0;
        
        &:first-child {
            border-top-left-radius: var(--border-radius);
            border-bottom-left-radius: var(--border-radius);
        }
        
        &:last-child {
            border-top-right-radius: var(--border-radius);
            border-bottom-right-radius: var(--border-radius);
        }
        
        &:not(:first-child) {
            margin-left: -1px;
        }
    }
}

/* ===== Loading Button ===== */
.btn-loading {
    position: relative;
    color: transparent !important;
    
    &::after {
        content: '';
        position: absolute;
        width: 1rem;
        height: 1rem;
        top: 50%;
        left: 50%;
        margin-left: -0.5rem;
        margin-top: -0.5rem;
        border: 2px solid transparent;
        border-top-color: currentColor;
        border-radius: 50%;
        animation: button-loading-spinner 1s ease infinite;
    }
}

@keyframes button-loading-spinner {
    from {
        transform: rotate(0turn);
    }
    to {
        transform: rotate(1turn);
    }
}

/* ===== Floating Action Button ===== */
.btn-fab {
    position: fixed;
    bottom: var(--spacing-xl);
    right: var(--spacing-xl);
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--border-radius-full);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-fixed);
    
    &:hover {
        transform: scale(1.1);
        box-shadow: var(--shadow-xl);
    }
}

/* ===== Mobile Optimizations ===== */
@media (max-width: 768px) {
    .btn {
        min-height: 44px; /* Touch target size */
        padding: var(--spacing-md) var(--spacing-lg);
    }
    
    .btn-sm {
        min-height: 36px;
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .btn-lg {
        min-height: 52px;
        padding: var(--spacing-lg) var(--spacing-xl);
    }
    
    .btn-fab {
        bottom: var(--spacing-lg);
        right: var(--spacing-lg);
    }
}

/* ===== RTL Support ===== */
[dir="rtl"] .btn-group .btn:not(:first-child) {
    margin-left: 0;
    margin-right: -1px;
}

[dir="rtl"] .btn-group .btn:first-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

[dir="rtl"] .btn-group .btn:last-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
}

/* ===== Print Styles ===== */
@media print {
    .btn {
        border: 1px solid #000 !important;
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
    }
    
    .btn-fab {
        display: none !important;
    }
}
