/**
 * UI Kit - Reusable Components
 * Built on design tokens from ui-tokens.css
 */

/* Base Reset & App Container */
.rt-app {
    min-height: 100vh;
    background: var(--rt-bg-primary);
    color: var(--rt-text-primary);
    font-family: var(--rt-font-family);
    direction: var(--rt-direction, rtl);
    line-height: var(--rt-line-height-normal);
}

/* Buttons */
.rt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--rt-space-sm) var(--rt-space-lg);
    font-size: var(--rt-font-size-base);
    font-weight: var(--rt-font-weight-semibold);
    border: none;
    border-radius: var(--rt-border-radius-md);
    cursor: pointer;
    transition: var(--rt-transition-all);
    text-decoration: none;
    white-space: nowrap;
    gap: var(--rt-space-sm);
}

.rt-btn-primary {
    background: var(--rt-gradient-primary);
    color: var(--rt-text-on-dark);
    box-shadow: var(--rt-shadow-md);
}

.rt-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--rt-shadow-lg);
}

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

.rt-btn-secondary:hover {
    background: var(--rt-surface-hover);
    border-color: var(--rt-border-color-strong);
}

.rt-btn-danger {
    background: #DC2626;
    color: var(--rt-text-on-dark);
}

.rt-btn-danger:hover {
    background: #B91C1C;
    transform: translateY(-2px);
}

.rt-btn-ghost {
    background: transparent;
    color: var(--rt-text-primary);
}

.rt-btn-ghost:hover {
    background: var(--rt-surface-hover);
}

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

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

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

/* Cards */
.rt-card {
    background: var(--rt-surface-elevated);
    border-radius: var(--rt-border-radius-lg);
    padding: var(--rt-space-xl);
    box-shadow: var(--rt-shadow-sm);
    border: 1px solid var(--rt-border-color);
    transition: var(--rt-transition-all);
}

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

.rt-card-header {
    margin-bottom: var(--rt-space-lg);
    padding-bottom: var(--rt-space-md);
    border-bottom: 1px solid var(--rt-border-color);
}

.rt-card-title {
    font-size: var(--rt-font-size-xl);
    font-weight: var(--rt-font-weight-bold);
    color: var(--rt-text-primary);
    margin: 0;
}

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

.rt-card-footer {
    margin-top: var(--rt-space-lg);
    padding-top: var(--rt-space-md);
    border-top: 1px solid var(--rt-border-color);
}

/* Inputs */
.rt-input {
    width: 100%;
    padding: var(--rt-space-md);
    font-size: var(--rt-font-size-base);
    font-family: var(--rt-font-family);
    color: var(--rt-text-primary);
    background: var(--rt-surface);
    border: 1px solid var(--rt-border-color);
    border-radius: var(--rt-border-radius-md);
    transition: var(--rt-transition-all);
}

.rt-input:focus {
    outline: none;
    border-color: var(--rt-primary);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.rt-input::placeholder {
    color: var(--rt-text-muted);
}

.rt-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

/* Badges */
.rt-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--rt-space-xs) var(--rt-space-sm);
    font-size: var(--rt-font-size-xs);
    font-weight: var(--rt-font-weight-semibold);
    border-radius: var(--rt-border-radius-full);
    white-space: nowrap;
}

.rt-badge-primary {
    background: var(--rt-gradient-primary);
    color: var(--rt-text-on-dark);
}

.rt-badge-success {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: var(--rt-text-on-dark);
}

.rt-badge-warning {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: var(--rt-text-on-dark);
}

.rt-badge-danger {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: var(--rt-text-on-dark);
}

.rt-badge-neutral {
    background: var(--rt-surface);
    color: var(--rt-text-secondary);
    border: 1px solid var(--rt-border-color);
}

/* Modals */
.rt-modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--rt-bg-overlay);
    backdrop-filter: blur(4px);
    z-index: var(--rt-z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--rt-space-lg);
}

.rt-modal {
    background: var(--rt-surface-elevated);
    border-radius: var(--rt-border-radius-xl);
    padding: var(--rt-space-xl);
    box-shadow: var(--rt-shadow-xl);
    border: 1px solid var(--rt-border-color);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    z-index: var(--rt-z-modal);
    position: relative;
}

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

.rt-modal-title {
    font-size: var(--rt-font-size-2xl);
    font-weight: var(--rt-font-weight-bold);
    color: var(--rt-text-primary);
    margin: 0;
}

.rt-modal-close {
    background: transparent;
    border: none;
    font-size: var(--rt-font-size-2xl);
    color: var(--rt-text-secondary);
    cursor: pointer;
    padding: var(--rt-space-xs);
    line-height: 1;
    transition: var(--rt-transition-base);
}

.rt-modal-close:hover {
    color: var(--rt-text-primary);
    transform: scale(1.1);
}

.rt-modal-body {
    margin-bottom: var(--rt-space-lg);
}

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

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

.rt-table th,
.rt-table td {
    padding: var(--rt-space-md);
    text-align: right;
    border-bottom: 1px solid var(--rt-border-color);
}

[dir="ltr"] .rt-table th,
[dir="ltr"] .rt-table td {
    text-align: left;
}

.rt-table th {
    font-weight: var(--rt-font-weight-semibold);
    color: var(--rt-text-primary);
    background: var(--rt-surface-hover);
}

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

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

/* Skeleton Loader */
.rt-skeleton {
    background: linear-gradient(
        90deg,
        var(--rt-surface) 0%,
        var(--rt-surface-hover) 50%,
        var(--rt-surface) 100%
    );
    background-size: 200% 100%;
    animation: rt-skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--rt-border-radius-md);
}

@keyframes rt-skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

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

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

.rt-skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* Chips/Tags */
.rt-chip {
    display: inline-flex;
    align-items: center;
    padding: var(--rt-space-xs) var(--rt-space-sm);
    font-size: var(--rt-font-size-xs);
    font-weight: var(--rt-font-weight-medium);
    border-radius: var(--rt-border-radius-full);
    background: var(--rt-surface);
    color: var(--rt-text-secondary);
    border: 1px solid var(--rt-border-color);
}

.rt-chip-primary {
    background: var(--rt-gradient-primary);
    color: var(--rt-text-on-dark);
    border-color: transparent;
}

/* Tooltips */
.rt-tooltip {
    position: relative;
}

.rt-tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: var(--rt-space-xs);
    padding: var(--rt-space-xs) var(--rt-space-sm);
    background: var(--rt-dark);
    color: var(--rt-text-on-dark);
    font-size: var(--rt-font-size-xs);
    border-radius: var(--rt-border-radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--rt-transition-base);
    z-index: var(--rt-z-tooltip);
}

.rt-tooltip:hover .rt-tooltip-content {
    opacity: 1;
}

/* Empty States */
.rt-empty {
    text-align: center;
    padding: var(--rt-space-3xl) var(--rt-space-xl);
    color: var(--rt-text-secondary);
}

.rt-empty-icon {
    font-size: var(--rt-font-size-4xl);
    margin-bottom: var(--rt-space-lg);
    opacity: 0.5;
}

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

.rt-empty-description {
    font-size: var(--rt-font-size-base);
    color: var(--rt-text-secondary);
}

/* Status Indicators */
.rt-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rt-text-muted);
}

.rt-status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
    animation: rt-pulse 2s ease-in-out infinite;
}

.rt-status-dot.offline {
    background: var(--rt-text-muted);
}

@keyframes rt-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Responsive Utilities */
@media (max-width: 768px) {
    .rt-modal {
        padding: var(--rt-space-lg);
        max-width: 95vw;
    }
    
    .rt-card {
        padding: var(--rt-space-lg);
    }
    
    .rt-modal-footer {
        flex-direction: column;
    }
    
    .rt-modal-footer .rt-btn {
        width: 100%;
    }
}

/* Utility Classes */
.rt-hidden {
    display: none !important;
}

.rt-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.rt-text-center {
    text-align: center;
}

.rt-text-right {
    text-align: right;
}

[dir="ltr"] .rt-text-right {
    text-align: left;
}

.rt-text-left {
    text-align: left;
}

[dir="rtl"] .rt-text-left {
    text-align: right;
}
