/* ============================================
   TeleVips SaaS - Reusable Components
   ============================================ */

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    text-decoration: none;
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

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

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-xs);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-base);
}

.btn-xl {
    padding: var(--space-5) var(--space-10);
    font-size: var(--font-size-lg);
}

/* Primary Button - Gradient */
.btn-primary {
    background: var(--gradient-primary);
    color: var(--text-primary);
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.btn-primary:hover:not(:disabled) {
    background: var(--gradient-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

/* Secondary Button - Outline */
.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-secondary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-glass-hover);
    border-color: var(--color-primary-400);
    transform: translateY(-2px);
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-glass);
    color: var(--text-primary);
}

/* Success Button */
.btn-success {
    background: var(--gradient-success);
    color: var(--text-primary);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

/* Danger Button */
.btn-danger {
    background: linear-gradient(135deg, var(--color-error-500) 0%, var(--color-error-600) 100%);
    color: var(--text-primary);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

/* Icon Button */
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-lg);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

/* Button with loading state */
.btn-loading {
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    transition: all var(--transition-base);
}

.card-hover:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-secondary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-glow {
    position: relative;
}

.card-glow::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: var(--gradient-primary);
    border-radius: inherit;
    opacity: 0;
    z-index: -1;
    transition: opacity var(--transition-base);
}

.card-glow:hover::before {
    opacity: 0.5;
}

.card-header {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-primary);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.card-description {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.card-body {
    flex: 1;
}

.card-footer {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-primary);
}

/* === Form Elements === */
.form-group {
    margin-bottom: var(--space-5);
}

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

.form-label-required::after {
    content: '*';
    color: var(--color-error-400);
    margin-left: var(--space-1);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.form-input:hover:not(:disabled) {
    border-color: var(--border-secondary);
}

.form-input:focus {
    border-color: var(--color-primary-500);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.form-input-error {
    border-color: var(--color-error-500);
}

.form-input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.form-input-success {
    border-color: var(--color-success-500);
}

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

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

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

/* Input with icon */
.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.input-icon svg {
    width: 18px;
    height: 18px;
}

.input-wrapper .form-input {
    padding-left: var(--space-10);
}

.input-action {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.input-action:hover {
    color: var(--text-primary);
}

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

.form-checkbox input,
.form-radio input {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary-500);
    cursor: pointer;
}

/* Select */
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2371717a'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    background-size: 18px;
    padding-right: var(--space-10);
}

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

.badge-primary {
    background: rgba(139, 92, 246, 0.15);
    color: var(--color-primary-400);
}

.badge-secondary {
    background: rgba(6, 182, 212, 0.15);
    color: var(--color-secondary-400);
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success-400);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning-400);
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-error-400);
}

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

/* === Alerts === */
.alert {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
}

.alert-icon {
    flex-shrink: 0;
}

.alert-icon svg {
    width: 20px;
    height: 20px;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-1);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--color-secondary-300);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--color-success-300);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--color-warning-300);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--color-error-300);
}

/* === Avatar === */
.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
    overflow: hidden;
}

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

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

.avatar-md {
    width: 40px;
    height: 40px;
    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-2xl);
}

/* === Skeleton Loader === */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-glass) 0%,
            var(--bg-glass-hover) 50%,
            var(--bg-glass) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1em;
    margin-bottom: var(--space-2);
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: var(--space-3);
}

.skeleton-circle {
    border-radius: var(--radius-full);
}

/* === Divider === */
.divider {
    height: 1px;
    background: var(--border-primary);
    margin: var(--space-6) 0;
}

.divider-vertical {
    width: 1px;
    height: 100%;
    background: var(--border-primary);
}

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

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

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

.progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: inherit;
    transition: width var(--transition-slow);
}

.progress-sm {
    height: 4px;
}

.progress-lg {
    height: 12px;
}

/* === Tabs === */
.tabs {
    display: flex;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--bg-glass);
    border-radius: var(--radius-lg);
}

.tab {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    background: transparent;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    text-align: center;
}

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

.tab.active {
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

/* === Tooltip === */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-md);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: var(--z-tooltip);
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

/* === Modal === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-2xl);
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

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

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

.modal-close {
    color: var(--text-tertiary);
    transition: color var(--transition-fast);
}

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

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    padding: var(--space-6);
    border-top: 1px solid var(--border-primary);
}

/* === Toast/Notification === */
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    z-index: var(--z-toast);
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    min-width: 320px;
    max-width: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    animation: slideInRight var(--transition-slow) ease-out;
}

.toast-icon {
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.toast-message {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.toast-close {
    color: var(--text-tertiary);
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-primary);
}

/* === Dropdown === */
.dropdown {
    position: relative;
}

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

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.dropdown-item:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

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

.dropdown-item-danger:hover {
    color: var(--color-error-400);
}

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

/* === Steps/Stepper === */
.steps {
    display: flex;
    gap: var(--space-4);
}

.step {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-tertiary);
    background: var(--bg-glass);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
}

.step.active .step-number {
    color: var(--text-primary);
    background: var(--gradient-primary);
    border-color: transparent;
}

.step.completed .step-number {
    background: var(--color-success-500);
    border-color: transparent;
    color: var(--text-primary);
}

.step-label {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    transition: color var(--transition-fast);
}

.step.active .step-label,
.step.completed .step-label {
    color: var(--text-primary);
}

.step-connector {
    flex: 1;
    height: 2px;
    background: var(--border-primary);
}

.step.completed+.step-connector,
.step.completed~.step-connector {
    background: var(--color-success-500);
}

/* === Empty State === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-16) var(--space-6);
}

.empty-state-icon {
    margin-bottom: var(--space-6);
    color: var(--text-tertiary);
}

.empty-state-icon svg {
    width: 64px;
    height: 64px;
}

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

.empty-state-description {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    max-width: 400px;
    margin-bottom: var(--space-6);
}

/* === Table === */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
    color: var(--text-tertiary);
    background: var(--bg-glass);
}

.table td {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

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

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

/* === Stat Card === */
.stat-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.stat-label {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
    color: var(--text-tertiary);
}

.stat-value {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.stat-change {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--font-size-sm);
}

.stat-change-positive {
    color: var(--color-success-400);
}

.stat-change-negative {
    color: var(--color-error-400);
}