/**
 * MAKLERTOOLS Platform - Component Styles
 * Reusable UI components
 */

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

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

.btn-primary {
    background-color: var(--color-primary);
    color: #1A1A1A;
}

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

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

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

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

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

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

.btn-danger:hover:not(:disabled) {
    background-color: #c0392b;
}

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

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

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

/* Cards */
.card {
    background-color: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

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

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

/* Alerts */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    margin-bottom: var(--space-md);
}

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

.alert-error {
    background-color: var(--color-error-bg);
    border-color: var(--color-error);
    color: var(--color-error);
}

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

.alert-info {
    background-color: var(--color-info-bg);
    border-color: var(--color-info);
    color: var(--color-info);
}

/* Forms */
.form-group {
    margin-bottom: var(--space-lg);
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-base);
    color: var(--color-text);
    background-color: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

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

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

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

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

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-full);
}

.badge-primary {
    background-color: var(--color-primary);
    color: var(--color-text-inverse);
}

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

.badge-warning {
    background-color: var(--color-warning);
    color: var(--color-text-inverse);
}

.badge-error {
    background-color: var(--color-error);
    color: white;
}

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

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

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

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

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

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

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

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    padding: var(--space-sm) 0;
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
}

.dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(4px);
}

/* Dropdown that opens upward (for bottom-positioned elements) */
.dropdown.dropdown-up .dropdown-menu {
    top: auto;
    bottom: 100%;
    transform: translateY(10px);
}

.dropdown.dropdown-up.open .dropdown-menu {
    transform: translateY(-4px);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text);
    transition: background-color var(--transition-fast);
}

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

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

/* Tables */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

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

.table th {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-text-muted);
    background-color: var(--color-bg-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table th:first-child {
    border-top-left-radius: var(--radius-md);
}

.table th:last-child {
    border-top-right-radius: var(--radius-md);
}

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

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

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

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

/* Table in Cards */
.card .table {
    margin: calc(var(--space-lg) * -1);
    margin-top: 0;
    width: calc(100% + var(--space-lg) * 2);
}

.card .table th:first-child,
.card .table td:first-child {
    padding-left: var(--space-xl);
}

.card .table th:last-child,
.card .table td:last-child {
    padding-right: var(--space-xl);
}

/* Stat Cards */
.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

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

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* Text Size Utilities */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }

/* Button block variant */
.btn-block {
    display: flex;
    width: 100%;
}

/* ========================================
   Consent Banner
   ======================================== */
.consent-banner {
    display: none;
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 90%;
    max-width: 500px;
    background: #1a1a1a;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 0 40px rgba(196, 164, 132, 0.3), 0 8px 32px rgba(0, 0, 0, 0.6);
    animation: consentFadeIn 0.3s ease;
}

.consent-banner.visible {
    display: block;
}

@keyframes consentFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.consent-banner-inner {
    padding: var(--space-lg);
}

.consent-header {
    margin-bottom: var(--space-lg);
}

.consent-header h3 {
    margin: 0 0 var(--space-sm) 0;
    font-size: var(--text-lg);
    color: var(--color-text);
}

.consent-header p {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.consent-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.consent-option {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-lg);
    padding: var(--space-md);
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
}

.consent-option-info {
    flex: 1;
}

.consent-option-info strong {
    color: var(--color-text);
    font-size: var(--text-base);
}

.consent-required {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-left: var(--space-xs);
}

.consent-option-info p {
    margin: var(--space-xs) 0 0 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* Toggle Switch */
.consent-toggle {
    flex-shrink: 0;
}

.consent-toggle input {
    display: none;
}

.toggle-label {
    display: block;
    width: 50px;
    height: 28px;
    background: var(--color-bg);
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-label::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

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

.consent-toggle input:checked + .toggle-label::after {
    transform: translateX(22px);
}

.toggle-label.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--color-primary);
}

.toggle-label.disabled::after {
    transform: translateX(22px);
}

/* Consent Buttons */
.consent-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    margin-bottom: var(--space-md);
}

.consent-btn {
    padding: var(--space-sm) var(--space-xl);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: all 0.2s ease;
}

.consent-btn-primary {
    background: var(--color-primary);
    color: #1a1a1a;
}

.consent-btn-primary:hover {
    background: var(--color-primary-dark);
}

/* Footer Links */
.consent-footer {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.consent-footer a {
    color: var(--color-text-muted);
    text-decoration: none;
}

.consent-footer a:hover {
    color: var(--color-primary);
}

/* Responsive */
@media (max-width: 600px) {
    .consent-banner {
        top: 70px;
        width: 95%;
        max-width: none;
        left: 2.5%;
        transform: none;
    }

    @keyframes consentFadeIn {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .consent-banner-inner {
        padding: var(--space-md);
    }

    .consent-option {
        flex-direction: column;
        gap: var(--space-md);
    }

    .consent-actions {
        flex-direction: column;
    }

    .consent-btn {
        width: 100%;
        text-align: center;
    }
}

/* ========================================
   Legal Content
   ======================================== */
.legal-content {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-xl) 0;
}

.legal-content h2 {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-primary);
}

.legal-content h3 {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

.legal-content p {
    margin-bottom: var(--space-md);
    line-height: 1.7;
    color: var(--color-text-secondary);
}

.legal-content ul {
    margin-bottom: var(--space-md);
    padding-left: var(--space-lg);
}

.legal-content li {
    margin-bottom: var(--space-xs);
    line-height: 1.6;
    color: var(--color-text-secondary);
}

.legal-content a {
    color: var(--color-primary);
    text-decoration: none;
}

.legal-content a:hover {
    text-decoration: underline;
}
