/**
 * Seguradora ALM - Components CSS
 * Estilos de componentes reutilizáveis
 */

/* ==================== Cards ==================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: none;
}

.card-header h6,
.card-header .card-title {
    margin: 0;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--gray-50);
}

/* Card variantes */
.card-hover {
    transition: var(--transition);
}

.card-hover:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-base);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

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

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

/* Secondary */
.btn-secondary {
    background: var(--secondary);
    color: var(--white);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-dark);
}

/* Success */
.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
}

/* Danger */
.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
}

/* Warning */
.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-warning:hover:not(:disabled) {
    background: var(--warning-dark);
}

/* Outline variants */
.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
    background: transparent;
}

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

.btn-outline-secondary {
    border-color: var(--gray-300);
    color: var(--text-secondary);
    background: transparent;
}

.btn-outline-secondary:hover:not(:disabled) {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-outline-danger {
    border-color: var(--danger);
    color: var(--danger);
    background: transparent;
}

.btn-outline-danger:hover:not(:disabled) {
    background: var(--danger);
    color: var(--white);
}

/* Button sizes */
.btn-sm {
    font-size: var(--font-size-sm);
    padding: 0.375rem 0.75rem;
}

.btn-lg {
    font-size: var(--font-size-lg);
    padding: 0.75rem 1.5rem;
}

/* Icon button */
.btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 2rem;
    height: 2rem;
}

/* ==================== Forms ==================== */
.form-label {
    display: block;
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    margin-bottom: 0.375rem;
    font-size: var(--font-size-sm);
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: var(--font-size-base);
    font-family: inherit;
    color: var(--text-primary);
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:disabled,
.form-control[readonly] {
    background: var(--gray-100);
    cursor: not-allowed;
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control.is-valid {
    border-color: var(--success);
}

/* Select */
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
}

/* Textarea */
textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Checkbox e Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 1.5rem;
}

.form-check-input {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* Input group */
.input-group {
    display: flex;
    width: 100%;
}

.input-group .form-control {
    border-radius: 0;
}

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

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

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.875rem;
    background: var(--gray-100);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.input-group-text:first-child {
    border-right: none;
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
}

.input-group-text:last-child {
    border-left: none;
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.input-group:focus-within .input-group-text {
    border-color: var(--primary);
}

/* Form feedback */
.invalid-feedback,
.valid-feedback {
    display: none;
    font-size: var(--font-size-sm);
    margin-top: 0.25rem;
}

.invalid-feedback {
    color: var(--danger);
}

.valid-feedback {
    color: var(--success);
}

.is-invalid ~ .invalid-feedback,
.is-valid ~ .valid-feedback {
    display: block;
}

/* ==================== Alerts ==================== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border: none;
    font-size: var(--font-size-base);
}

.alert-success {
    background: var(--success-light);
    color: var(--success-dark);
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.alert-info {
    background: var(--info-light);
    color: var(--info-dark);
}

/* ==================== Badges ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary,
.bg-primary.badge {
    background: var(--primary);
    color: var(--white);
}

.badge-secondary,
.bg-secondary.badge {
    background: var(--gray-500);
    color: var(--white);
}

.badge-success,
.bg-success.badge {
    background: var(--success);
    color: var(--white);
}

.badge-danger,
.bg-danger.badge {
    background: var(--danger);
    color: var(--white);
}

.badge-warning,
.bg-warning.badge {
    background: var(--warning);
    color: var(--white);
}

.badge-info,
.bg-info.badge {
    background: var(--info);
    color: var(--white);
}

/* Badge light variants */
.badge-light-primary {
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--primary);
}

.badge-light-success {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-light-danger {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.badge-light-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
}

/* ==================== Tables ==================== */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    background: var(--gray-50);
    white-space: nowrap;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table-striped tbody tr:nth-child(odd) {
    background: var(--gray-50);
}

/* ==================== Dropdowns ==================== */
.dropdown-menu {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 0.5rem 0;
    min-width: 200px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    transition: var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.dropdown-item.active,
.dropdown-item:active {
    background: var(--primary);
    color: var(--white);
}

.dropdown-header {
    padding: 0.5rem 1rem;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-top: 1px solid var(--border-color);
}

/* ==================== Modal ==================== */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    gap: 0.5rem;
}

/* ==================== Spinner ==================== */
.spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 2px;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

/* ==================== Avatar ==================== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: var(--font-size-sm);
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: var(--font-size-lg);
}

.avatar-xl {
    width: 80px;
    height: 80px;
    font-size: var(--font-size-xl);
}

/* ==================== Empty State ==================== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    font-size: var(--font-size-sm);
    max-width: 300px;
    margin: 0 auto;
}

/* ==================== Loading Overlay ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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