/* ========================================
   COMPONENTS CSS - Portal de Treinamento TOTVS
   Biblioteca de Componentes Reutilizáveis
   ======================================== */

/* ========================================
   Cards
   ======================================== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.card-body {
    color: var(--text-secondary);
}

.card-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Card Variants */
.card-primary {
    border-color: var(--primary);
    border-top-width: 3px;
}

.card-primary .card-header {
    border-bottom-color: var(--primary-lighter);
}

.card-success {
    border-color: var(--success);
    border-top-width: 3px;
}

.card-warning {
    border-color: var(--warning);
    border-top-width: 3px;
}

.card-danger {
    border-color: var(--danger);
    border-top-width: 3px;
}

/* Featured Cards */
.card-featured {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
}

.card-featured .card-title,
.card-featured .card-body {
    color: white;
}

.card-featured .card-header {
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.9375rem;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    outline: none;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Button Ripple Effect */
.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

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

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

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

.btn-success:hover {
    background: var(--success-dark);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

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

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

.btn-danger:hover {
    background: var(--danger-dark);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Button Outline */
.btn-outline-primary {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

.btn-outline-secondary {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
}

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

/* Button Sizes */
.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1.0625rem;
}

/* Button States */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Button Group */
.btn-group {
    display: inline-flex;
    gap: -1px;
}

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

.btn-group .btn:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* ========================================
   Badges
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    line-height: 1;
}

.badge-primary {
    background: var(--primary-lighter);
    color: var(--primary-dark);
}

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

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

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

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

.badge-secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

/* Badge Sizes */
.badge-sm {
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
}

.badge-lg {
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
}

/* ========================================
   Alerts
   ======================================== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    position: relative;
}

.alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.alert-message {
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Alert Variants */
.alert-info {
    background: var(--info-bg);
    border-color: var(--info-light);
    color: var(--info-dark);
}

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

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

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

/* Dismissible Alert */
.alert-dismissible {
    padding-right: 3rem;
}

.alert-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-close:hover {
    opacity: 1;
}

/* ========================================
   Tables
   ======================================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

.table thead {
    background: var(--bg-secondary);
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.table tbody tr {
    transition: background-color var(--transition-fast);
}

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

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Table Variants */
.table-striped tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

.table-bordered {
    border: 1px solid var(--border-color);
}

.table-bordered th,
.table-bordered td {
    border: 1px solid var(--border-color);
}

.table-sm th,
.table-sm td {
    padding: 0.5rem;
}

/* ========================================
   Forms
   ======================================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
    background: var(--card-bg);
    color: var(--text-primary);
}

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

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

.form-control:disabled {
    background: var(--bg-secondary);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Input Sizes */
.form-control-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.form-control-lg {
    padding: 0.875rem 1rem;
    font-size: 1.0625rem;
}

/* Textarea */
.form-control[type="textarea"],
textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Select */
select.form-control {
    cursor: pointer;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.form-check-input {
    width: 18px;
    height: 18px;
    margin-right: 0.5rem;
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
}

/* Form Help Text */
.form-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

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

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

.invalid-feedback {
    font-size: 0.8125rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

.valid-feedback {
    font-size: 0.8125rem;
    color: var(--success);
    margin-top: 0.25rem;
}

/* ========================================
   Modals
   ======================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Modal Sizes */
.modal-sm {
    max-width: 300px;
}

.modal-lg {
    max-width: 800px;
}

.modal-xl {
    max-width: 1140px;
}

/* ========================================
   Tabs
   ======================================== */
.tabs {
    border-bottom: 2px solid var(--border-color);
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-button {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: var(--primary);
    background: var(--bg-hover);
}

.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
    animation: fadeIn var(--transition-base);
}

.tab-content.active {
    display: block;
}

/* ========================================
   Accordion
   ======================================== */
.accordion {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1rem;
}

.accordion-item {
    border-bottom: 1px solid var(--border-color);
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-header {
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    transition: all var(--transition-fast);
    user-select: none;
}

.accordion-header:hover {
    background: var(--bg-tertiary);
}

.accordion-header.active {
    background: var(--primary-lighter);
    color: var(--primary-dark);
}

.accordion-icon {
    transition: transform var(--transition-fast);
}

.accordion-header.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-base);
}

.accordion-content.active {
    padding: 1.25rem;
    max-height: 1000px;
}

/* ========================================
   Progress
   ======================================== */
.progress {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow) ease;
    position: relative;
    overflow: hidden;
}

.progress-bar.progress-bar-striped {
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
}

.progress-bar.progress-bar-animated {
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% { background-position: 1rem 0; }
    100% { background-position: 0 0; }
}

/* Progress Sizes */
.progress-sm {
    height: 4px;
}

.progress-lg {
    height: 16px;
}

/* Progress Label */
.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

/* ========================================
   Tooltips
   ======================================== */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 0.8125rem;
    border-radius: var(--radius);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    margin-bottom: 0.5rem;
    z-index: var(--z-tooltip);
}

.tooltip:hover .tooltip-content {
    opacity: 1;
    visibility: visible;
}

/* Tooltip Arrow */
.tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* ========================================
   Dropdowns
   ======================================== */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    cursor: pointer;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 0.5rem 0;
    margin-top: 0.25rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
    z-index: var(--z-dropdown);
}

.dropdown.active .dropdown-menu,
.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-secondary);
    color: var(--primary);
}

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

/* ========================================
   Pagination
   ======================================== */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 1.5rem 0;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.page-link:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    color: var(--primary);
}

.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.page-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   Spinners
   ======================================== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

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

.spinner-sm {
    width: 16px;
    height: 16px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

/* ========================================
   Utility Components
   ======================================== */

/* Divider */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 0;
}

/* Avatar */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 1rem;
}

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

/* Chips */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.chip-removable {
    padding-right: 0.375rem;
}

.chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chip-remove:hover {
    background: var(--danger);
}

/* ========================================
   Responsive Utilities
   ======================================== */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .card {
        padding: 1rem;
    }
    
    .modal {
        margin: 0.5rem;
    }
    
    .table-container {
        margin: 0 -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

@media (min-width: 769px) {
    .show-mobile {
        display: none !important;
    }
}

/* ========================================
   Print Utilities
   ======================================== */
@media print {
    .no-print {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
    
    .btn,
    .dropdown,
    .pagination,
    .modal-backdrop {
        display: none !important;
    }
}
