/* ============================================
   TRADENIX DESIGN SYSTEM
   Unified component library for consistent UI
   ============================================ */

/* ============================================
   1. TYPOGRAPHY SYSTEM
   ============================================ */

/* Page Titles */
.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 20px 0;
    line-height: 1.3;
}

/* Section Titles */
.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 16px 0;
}

/* Subsection Titles */
.subsection-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin: 0 0 12px 0;
}

/* Body Text */
.text-body {
    font-size: 0.875rem;
    color: var(--color-text-primary);
    line-height: 1.5;
}

/* Small/Meta Text */
.text-small,
.text-meta {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* Text Colors */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }

/* ============================================
   2. SPACING SYSTEM
   ============================================ */

/* Margins */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }
.mt-6 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 24px; }
.mb-6 { margin-bottom: 32px; }

/* Padding */
.p-0 { padding: 0; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 24px; }
.p-6 { padding: 32px; }

/* ============================================
   3. PAGE STRUCTURE
   ============================================ */

/* Page Container */
.page {
    padding: 0;
}

/* Page Header - Title + Actions */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header .page-title {
    margin-bottom: 0;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   4. BREADCRUMBS (Standardized)
   ============================================ */

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    margin-bottom: 12px;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    flex-wrap: wrap;
}

.breadcrumbs a {
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.breadcrumbs a:hover {
    color: var(--color-text-primary);
}

.breadcrumbs .separator {
    color: var(--color-text-muted);
    font-size: 0.7rem;
}

.breadcrumbs .current {
    color: var(--color-text-primary);
    font-weight: 500;
}

.breadcrumbs i {
    font-size: 0.8rem;
}

/* ============================================
   5. CARD SYSTEM
   ============================================ */

.card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.card-sm {
    padding: 16px;
}

.card-lg {
    padding: 32px;
}

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

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

.card-body {
    /* Default body styling */
}

.card-footer {
    padding-top: 16px;
    margin-top: 16px;
    border-top: 1px solid var(--color-border);
}

/* Card Variants */
.card-elevated {
    background: var(--color-bg-elevated);
    box-shadow: var(--shadow-md);
}

.card-flat {
    background: transparent;
    border: none;
    padding: 0;
}

/* ============================================
   6. BUTTON SYSTEM
   ============================================ */

/* Base Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    line-height: 1.4;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

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

/* Primary Button */
.btn-primary {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}

/* Secondary Button */
.btn-secondary,
.button {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-strong);
}

.btn-secondary:hover:not(:disabled),
.button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Danger Button */
.btn-danger {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
}

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

/* Success Button */
.btn-success {
    background: var(--color-success);
    color: #fff;
    border-color: var(--color-success);
}

.btn-success:hover:not(:disabled) {
    background: #2ea043;
    border-color: #2ea043;
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
    padding: 6px 10px;
}

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

/* Button Sizes */
.btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
}

/* Icon Button */
.btn-icon {
    padding: 8px;
    min-width: 36px;
    min-height: 36px;
}

.btn-icon i {
    font-size: 1rem;
}

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

/* ============================================
   7. FORM SYSTEM
   ============================================ */

/* Form Container */
.form-container {
    max-width: 600px;
    margin: 0 auto;
}

/* Form Card (for standalone forms) */
.form-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 600px;
    margin: 0 auto;
}

/* Form Group */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* Form Label */
.form-group label,
.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* Form Inputs */
.form-control,
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="tel"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.875rem;
    font-family: var(--font-sans);
    color: var(--color-text-primary);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.form-control:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control:disabled,
.form-group input:disabled,
.form-group select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--color-bg-tertiary);
}

.form-control[readonly],
.form-group input[readonly] {
    opacity: 0.7;
    cursor: default;
}

/* Form Help Text */
.form-help,
.form-text {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Form Row (2-column layout) */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Form Section */
.form-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 16px;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.form-actions-right {
    justify-content: flex-end;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.form-check label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 400;
}

/* Inline Form */
.form-inline {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
}

/* ============================================
   8. TABLE SYSTEM
   ============================================ */

.table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table thead th,
.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    background: var(--color-bg-tertiary);
    border-bottom: 1px solid var(--color-border);
}

.table thead th:first-child,
.data-table thead th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.table thead th:last-child,
.data-table thead th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

.table tbody td,
.data-table tbody td {
    padding: 12px 16px;
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

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

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

/* Table Variants */
.table-compact td,
.table-compact th {
    padding: 8px 12px;
}

.table-striped tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Table Actions Column */
.table .actions,
.data-table .actions {
    text-align: right;
    white-space: nowrap;
}

.table .actions .btn,
.data-table .actions .btn,
.table .actions .button,
.data-table .actions .button {
    padding: 4px 10px;
    font-size: 0.75rem;
}

/* ============================================
   9. BADGE SYSTEM
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Badge Variants */
.badge-default {
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border-strong);
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.badge-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    border: 1px solid rgba(210, 153, 34, 0.3);
}

.badge-info {
    background: var(--color-info-bg);
    color: var(--color-info);
    border: 1px solid rgba(88, 166, 255, 0.3);
}

/* Status Dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.success,
.status-dot.active,
.status-dot.green {
    background: var(--color-success);
}

.status-dot.danger,
.status-dot.error,
.status-dot.red {
    background: var(--color-danger);
}

.status-dot.warning,
.status-dot.pending,
.status-dot.yellow {
    background: var(--color-warning);
}

.status-dot.muted,
.status-dot.inactive,
.status-dot.grey {
    background: var(--color-text-muted);
}

/* ============================================
   10. ALERT / MESSAGE SYSTEM
   ============================================ */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.alert-success {
    background: var(--color-success-bg);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: var(--color-success);
}

.alert-danger,
.alert-error {
    background: var(--color-danger-bg);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--color-danger);
}

.alert-warning {
    background: var(--color-warning-bg);
    border: 1px solid rgba(210, 153, 34, 0.3);
    color: var(--color-warning);
}

.alert-info {
    background: var(--color-info-bg);
    border: 1px solid rgba(88, 166, 255, 0.3);
    color: var(--color-info);
}

/* Status Message (for AJAX responses) */
.status-message {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    text-align: center;
    margin-bottom: 16px;
}

.status-message.success {
    background: var(--color-success-bg);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: var(--color-success);
}

.status-message.error {
    background: var(--color-danger-bg);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--color-danger);
}

.status-message.hidden {
    display: none;
}

/* ============================================
   11. TABS SYSTEM
   ============================================ */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab {
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
}

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

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

/* ============================================
   12. MODAL SYSTEM
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.modal-body {
    margin-bottom: 20px;
}

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

/* ============================================
   13. EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 0.875rem;
    margin-bottom: 20px;
}

/* ============================================
   14. LOADING STATES
   ============================================ */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   15. UTILITY CLASSES
   ============================================ */

/* Display */
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-inline { display: inline; }
.d-inline-flex { display: inline-flex; }

/* Flexbox */
.flex-wrap { flex-wrap: wrap; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.align-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-start { justify-content: flex-start; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Width */
.w-100 { width: 100%; }
.w-auto { width: auto; }

/* Visibility */
.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* Cursor */
.cursor-pointer { cursor: pointer; }

/* ============================================
   16. RESPONSIVE HELPERS
   ============================================ */

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .form-card {
        padding: 20px;
    }
    
    .card {
        padding: 16px;
    }
    
    .table-responsive {
        overflow-x: auto;
    }
}

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