/* ============================================
   COMPONENT STYLES
   ============================================ */

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.625rem 1.25rem;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: 1;
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary-600);
    color: var(--text-white);
    border-color: var(--primary-600);
}

.btn-primary:hover {
    background: var(--primary-700);
    border-color: var(--primary-700);
    box-shadow: var(--shadow-glow);
    color: var(--text-white);
}

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

.btn-secondary:hover {
    background: var(--primary-50);
    border-color: var(--primary-400);
    color: var(--primary-700);
}

.btn-accent {
    background: var(--accent-500);
    color: var(--text-white);
    border-color: var(--accent-500);
}

.btn-accent:hover {
    background: var(--accent-600);
    border-color: var(--accent-600);
    box-shadow: var(--shadow-glow-accent);
    color: var(--text-white);
}

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

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

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

.btn-danger:hover {
    background: var(--danger-600);
    border-color: var(--danger-600);
}

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

.btn-success:hover {
    background: var(--success-600);
    border-color: var(--success-600);
}

.btn-whatsapp {
    background: #25D366;
    color: var(--text-white);
    border-color: #25D366;
}

.btn-whatsapp:hover {
    background: #128C7E;
    border-color: #128C7E;
    color: var(--text-white);
}

.btn-google {
    background: #ffffff;
    color: var(--text-primary);
    border-color: var(--gray-300);
}

.btn-google:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    box-shadow: var(--shadow-sm);
}

/* Button Sizes */
.btn-xs {
    padding: 0.375rem 0.75rem;
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: var(--text-sm);
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: var(--text-base);
}

.btn-xl {
    padding: 1rem 2rem;
    font-size: var(--text-lg);
    border-radius: var(--radius-xl);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 0.625rem;
    width: 40px;
    height: 40px;
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
    padding: 0.375rem;
}

.btn:disabled, .btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn .btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-card-hover);
}

.card-body {
    padding: var(--space-5);
}

.card-header {
    padding: var(--space-5);
    border-bottom: 1px solid var(--gray-100);
}

.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

/* Stat Card */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    transition: all var(--transition-base);
    box-shadow: var(--shadow-card);
}

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

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xl);
    flex-shrink: 0;
}

.stat-card-icon.primary {
    background: var(--primary-100);
    color: var(--primary-600);
}

.stat-card-icon.accent {
    background: var(--accent-100);
    color: var(--accent-600);
}

.stat-card-icon.success {
    background: var(--success-100);
    color: var(--success-600);
}

.stat-card-icon.warning {
    background: var(--warning-100);
    color: var(--warning-600);
}

.stat-card-icon.danger {
    background: var(--danger-100);
    color: var(--danger-600);
}

.stat-card-info {
    flex: 1;
}

.stat-card-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.stat-card-value {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
}

.stat-card-change {
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    margin-top: var(--space-1);
}

.stat-card-change.positive { color: var(--success-600); }
.stat-card-change.negative { color: var(--danger-600); }

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.25rem 0.625rem;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    border-radius: var(--radius-full);
    white-space: nowrap;
    line-height: 1.4;
}

.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-accent {
    background: var(--accent-100);
    color: var(--accent-700);
}

.badge-success {
    background: var(--success-100);
    color: var(--success-700);
}

.badge-warning {
    background: var(--warning-100);
    color: var(--warning-600);
}

.badge-danger {
    background: var(--danger-100);
    color: var(--danger-700);
}

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-featured {
    background: linear-gradient(135deg, var(--accent-400), var(--accent-600));
    color: var(--text-white);
}

.badge-urgent {
    background: linear-gradient(135deg, var(--danger-400), var(--danger-600));
    color: var(--text-white);
}

.badge-new {
    background: linear-gradient(135deg, var(--success-400), var(--success-600));
    color: var(--text-white);
}

/* Dot indicator */
.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.badge-dot.active { background: var(--success-500); }
.badge-dot.inactive { background: var(--gray-400); }
.badge-dot.pending { background: var(--warning-500); }

/* ---- FORM ELEMENTS ---- */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-label .required {
    color: var(--danger-500);
    margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: var(--gray-400);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--danger-500);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--gray-400);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 6.646a.5.5 0 0 1 .708 0L8 9.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

.form-help {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--danger-500);
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.form-input-icon {
    position: relative;
}

.form-input-icon .form-input {
    padding-left: 2.5rem;
}

.form-input-icon .icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-600);
    cursor: pointer;
}

.form-check-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: var(--transition-base);
    border-radius: var(--radius-full);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-base);
    border-radius: 50%;
    box-shadow: var(--shadow-xs);
}

.toggle input:checked + .toggle-slider {
    background-color: var(--primary-600);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ---- TAGS ---- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.25rem 0.5rem;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    background: var(--gray-100);
    border-radius: var(--radius-md);
    line-height: 1.4;
}

.tag-removable {
    cursor: pointer;
}

.tag-removable:hover {
    background: var(--gray-200);
}

.tag-primary {
    background: var(--primary-50);
    color: var(--primary-700);
}

/* ---- AVATAR ---- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--primary-100);
    color: var(--primary-700);
    font-weight: var(--weight-semibold);
}

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

.avatar-xs { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-sm { width: 36px; height: 36px; font-size: var(--text-sm); }
.avatar-md { width: 44px; height: 44px; font-size: var(--text-base); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar-xl { width: 72px; height: 72px; font-size: var(--text-2xl); }
.avatar-2xl { width: 96px; height: 96px; font-size: var(--text-3xl); }

.avatar-square {
    border-radius: var(--radius-lg);
}

/* ---- TABS ---- */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    gap: var(--space-1);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab-btn:hover {
    color: var(--primary-600);
}

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

.tab-content {
    padding: var(--space-5) 0;
}

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

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--space-2);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    border: none;
    background: none;
    text-align: left;
}

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

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: var(--space-2) 0;
}

/* ---- PROGRESS BAR ---- */
.progress {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
    background: var(--primary-500);
}

.progress-bar.success { background: var(--success-500); }
.progress-bar.warning { background: var(--warning-500); }
.progress-bar.danger { background: var(--danger-500); }
.progress-bar.accent { background: var(--accent-500); }
.progress-bar.gradient {
    background: linear-gradient(90deg, var(--primary-500), var(--accent-500));
}

.progress-lg { height: 12px; }
.progress-sm { height: 4px; }

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.4;
}

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

.empty-state-text {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    max-width: 400px;
    margin: 0 auto var(--space-6);
}

/* ---- TABLE ---- */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table th, .table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.table th {
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    background: var(--gray-50);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

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

/* ---- DIVIDER ---- */
.divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text-tertiary);
    font-size: var(--text-sm);
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

/* ---- ACCORDION ---- */
.accordion-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-2);
    overflow: hidden;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    cursor: pointer;
    font-weight: var(--weight-medium);
    transition: background var(--transition-fast);
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.accordion-header:hover {
    background: var(--gray-50);
}

.accordion-header .icon {
    transition: transform var(--transition-base);
    color: var(--gray-400);
}

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

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-item.active .accordion-body {
    max-height: 500px;
}

.accordion-content {
    padding: 0 var(--space-4) var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

/* ---- TOOLTIP ---- */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.375rem 0.75rem;
    background: var(--gray-800);
    color: var(--text-white);
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    pointer-events: none;
    z-index: var(--z-dropdown);
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}
