/* Buttons - Unified Button System */

/* Base Button */
.btn {
    height: var(--size-md);
    padding: 0 var(--space-3);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-base);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s; /* Specific properties only */
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-align: center;
    box-sizing: border-box;
}

/* Button Variants */
.btn--primary {
    background: var(--primary);
    color: white;
}

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

.btn--secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    background: var(--bg-muted);
}

.btn--warning {
    background: var(--bg);
    color: var(--error);
    border: 1px solid var(--border);
}

.btn--warning:hover {
    background: rgba(220, 38, 38, 0.1);
    border-color: var(--error);
}

.btn--link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: 0;
    height: auto;
}

.btn--link:hover {
    text-decoration: underline;
}

/* Button Sizes */
.btn--sm {
    height: var(--size-sm);
    padding: 0 var(--space-2);
    font-size: var(--font-size-sm);
}

.btn--lg {
    height: var(--size-lg);
    padding: 0 var(--space-6);
    font-size: var(--font-size-md);
}

/* Icon Button */
.btn--icon {
    width: var(--size-md);
    height: var(--size-md);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-muted);
    font-size: var(--font-size-md);
}

.btn--icon:hover {
    background: var(--bg-muted);
    border-color: var(--primary);
    color: var(--primary);
}

/* Icon Button Size Variants */
.btn--icon.btn--sm {
    width: var(--size-sm);
    height: var(--size-sm);
}

.btn--icon.btn--lg {
    width: var(--size-lg);
    height: var(--size-lg);
}

/* Muted Button (for add field, upload logo, etc.) */
.btn--muted {
    background: var(--bg-muted);
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: var(--font-size-xs);
    padding: 0 var(--space-2);
}

.btn--muted:hover {
    background: var(--bg-accent);
    border-color: var(--primary);
    color: var(--primary);
}

/* Dashed Button (for add line item) */
.btn--dashed {
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    width: 100%;
    height: auto;
}

.btn--dashed:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
    border-style: solid;
}

/* Remove Button (for line items, custom fields) */
.btn--remove {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
    padding: var(--space-1);
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s, color 0.15s; /* Specific properties only */
    flex-shrink: 0;
    height: var(--size-md);
    width: var(--size-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn--remove:hover {
    color: var(--error);
    background: rgba(220, 38, 38, 0.1);
}

/* Remove Button - Destructive (for custom fields) */
.btn--remove-destructive {
    height: var(--size-md);
    width: var(--size-md);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 1rem;
}

.btn--remove-destructive:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

/* Remove Logo Button (circular, absolute positioned) */
.btn--remove-logo {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--error);
    color: white;
    cursor: pointer;
    font-size: var(--font-size-sm);
    line-height: 1;
    transition: background-color 0.15s, transform 0.15s; /* Specific properties, transform for scale */
    box-shadow: var(--shadow-sm);
}

.btn--remove-logo:hover {
    background: #b91c1c;
    transform: scale(1.1);
}

/* Export Button (large, prominent) */
.btn--export {
    width: auto;
    min-width: 200px;
    height: var(--size-lg);
    font-size: var(--font-size-md);
    font-weight: 500;
    padding: 0 var(--space-6);
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    border: none;
    margin: 0 auto;
}

.btn--export:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn--export:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Info Text Button (header) */
.btn--info-text {
    background: none;
    border: none;
    padding: 0;
    font-size: var(--font-size-xs);
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.15s;
    flex-shrink: 0;
    margin-left: auto;
    height: auto;
}

.btn--info-text:hover {
    color: var(--text-muted);
    text-decoration: underline;
}

/* Legacy class names for backward compatibility */
.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-muted);
}

.btn-warning {
    background: var(--bg);
    color: var(--error);
    border: 1px solid var(--border);
}

.btn-warning:hover {
    background: rgba(220, 38, 38, 0.1);
    border-color: var(--error);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: 0;
    height: auto;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-icon {
    width: var(--size-md);
    height: var(--size-md);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-muted);
    font-size: var(--font-size-md);
}

.btn-icon:hover {
    background: var(--bg-muted);
    border-color: var(--primary);
    color: var(--primary);
}

/* Legacy icon button size variants */
.btn-icon.btn--sm {
    width: var(--size-sm);
    height: var(--size-sm);
}

.btn-icon.btn--lg {
    width: var(--size-lg);
    height: var(--size-lg);
}

.btn-upload-logo,
.btn-add-field {
    height: var(--size-md);
    padding: 0 var(--space-2);
    margin-top: 0; /* Align with other form fields */
    font-size: var(--font-size-xs);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s; /* Specific properties only */
    display: flex !important; /* Override .form-group label display: block */
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-sizing: border-box;
    will-change: auto; /* Hint browser about potential changes */
}

.btn-upload-logo.hidden,
.btn-add-field.hidden {
    display: none !important; /* Override base display when hidden */
}

.btn-upload-logo:hover,
.btn-add-field:hover {
    background: var(--bg-accent);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-add-line {
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s; /* Specific properties only */
    width: 100%;
    height: auto;
}

.btn-add-line:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
    border-style: solid;
}

.btn-remove-custom-field {
    height: var(--size-md);
    width: var(--size-md);
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: start;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s; /* Specific properties only */
}

.btn-remove-custom-field:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.btn-remove-logo {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--error);
    color: white;
    cursor: pointer;
    font-size: var(--font-size-sm);
    line-height: 1;
    transition: background-color 0.15s, transform 0.15s; /* Specific properties, transform for scale */
    box-shadow: var(--shadow-sm);
}

.btn-remove-logo:hover {
    background: #b91c1c;
    transform: scale(1.1);
}

.form-export-btn {
    width: auto;
    min-width: 200px;
    height: var(--size-lg);
    font-size: var(--font-size-md);
    font-weight: 500;
    padding: 0 var(--space-6);
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease; /* Specific properties only */
    margin: 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.form-export-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-export-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.btn-info-text {
    background: none;
    border: none;
    padding: 0;
    font-size: var(--font-size-xs);
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.15s;
    flex-shrink: 0;
    margin-left: auto;
    height: auto;
}

.btn-info-text:hover {
    color: var(--text-muted);
    text-decoration: underline;
}

/* Share Button Group */
.share-button-group {
    display: inline-flex;
    gap: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

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

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

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

.share-button-group .btn + .btn {
    border-left: none;
}

.share-button-group .btn:hover {
    position: relative;
    z-index: 1;
    border-left: 1px solid var(--primary);
}

.share-button-group .btn svg {
    display: block;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

