/* =============================================================
   Connect N — Component Library
   Depends on: design-tokens.css, base.css
   ============================================================= */

/* ================== BUTTONS ==================
   .btn                    - base
   .btn-primary            - Gold (primary actions)
   .btn-navy               - Navy (brand/chrome actions)
   .btn-secondary          - outlined
   .btn-ghost              - minimal
   .btn-danger             - urgent actions (delete, logout)
   .btn-success            - confirm actions
   Sizes: .btn-sm, .btn (default), .btn-lg
   ============================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--touch-target-min);
    padding: var(--space-2) var(--space-4);
    border: 1.5px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    line-height: 1;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn i, .btn svg { font-size: 1.1em; flex-shrink: 0; }

/* Primary — Gold (the main action color) */
.btn-primary {
    background: var(--color-action);
    border-color: var(--color-action);
    color: var(--color-on-action);
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover {
    background: var(--color-action-hover);
    border-color: var(--color-action-hover);
    color: var(--color-on-action);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.btn-primary:active {
    background: var(--color-action-active);
    transform: translateY(0);
}

/* Navy — brand/chrome actions */
.btn-navy {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-on-primary);
    box-shadow: var(--shadow-xs);
}
.btn-navy:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: var(--color-on-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Secondary — outlined */
.btn-secondary {
    background: var(--surface-card);
    border-color: var(--border-default);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--surface-card-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

/* Ghost — minimal */
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--surface-sunken);
    color: var(--text-primary);
}

/* Danger / Success */
.btn-danger {
    background: var(--color-urgent);
    border-color: var(--color-urgent);
    color: var(--color-on-urgent);
}
.btn-danger:hover { background: var(--color-urgent-hover); border-color: var(--color-urgent-hover); color: var(--color-on-urgent); }

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

/* Sizes */
.btn-sm {
    min-height: 36px;
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
    gap: var(--space-1);
}
.btn-lg {
    min-height: var(--touch-target-comfy);
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-md);
}

.btn-block { width: 100%; }

.btn-icon {
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    padding: 0;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}
.btn-icon.btn-sm { width: 36px; height: 36px; }
.btn-icon.btn-lg { width: var(--touch-target-comfy); height: var(--touch-target-comfy); }

.btn-group {
    display: inline-flex;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
}
.btn-group .btn { border-radius: 0; box-shadow: none; }
.btn-group .btn:first-child { border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); }
.btn-group .btn:last-child  { border-top-right-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }
.btn-group .btn + .btn { margin-left: -1.5px; }


/* ================== FORMS ==================
   .field          - wrapper
   .label          - field label
   .input, .select, .textarea
   .help-text, .error-text
   ============================================ */

.field { margin-bottom: var(--space-5); }
.field:last-child { margin-bottom: 0; }

.label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    letter-spacing: 0.01em;
}
.label .required { color: var(--color-urgent); margin-left: 2px; }
.label .optional { color: var(--text-muted); font-weight: var(--weight-regular); margin-left: 4px; font-size: var(--text-xs); }

.input, .select, .textarea {
    display: block;
    width: 100%;
    min-height: var(--touch-target-min);
    padding: var(--space-2) var(--space-3);
    border: 1.5px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--surface-card);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-md);
    line-height: var(--leading-snug);
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out),
                background var(--duration-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }

.input:hover, .select:hover, .textarea:hover {
    border-color: var(--border-strong);
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}
.input:disabled, .select:disabled, .textarea:disabled {
    background: var(--surface-sunken);
    color: var(--text-disabled);
    cursor: not-allowed;
}
.input[readonly] { background: var(--surface-sunken); }

.textarea { min-height: 100px; resize: vertical; padding-top: var(--space-3); }

/* Select arrow */
.select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 6 8 10 12 6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    background-size: 16px;
    padding-right: var(--space-10);
}

/* Error state */
.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea {
    border-color: var(--color-urgent);
}
.field.has-error .input:focus,
.field.has-error .select:focus,
.field.has-error .textarea:focus {
    box-shadow: var(--shadow-focus-error);
}

.help-text {
    display: block;
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: var(--leading-normal);
}
.error-text {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    color: var(--color-urgent);
}

/* Input group (button/icon prefix/suffix) */
.input-group { position: relative; display: flex; }
.input-group .input { flex: 1; }
.input-group .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group .input:not(:last-child)  { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group-btn {
    display: flex; align-items: center; justify-content: center;
    padding: 0 var(--space-3);
    border: 1.5px solid var(--border-default);
    background: var(--surface-sunken);
    color: var(--text-secondary);
    cursor: pointer;
}
.input-group-btn:first-child { border-right: 0; border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); }
.input-group-btn:last-child  { border-left: 0;  border-top-right-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }

/* Checkbox / Radio */
.check, .radio {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    user-select: none;
    min-height: var(--touch-target-min);
}
.check input, .radio input {
    width: 20px; height: 20px;
    accent-color: var(--color-action);
    cursor: pointer;
}
.check-label, .radio-label { font-size: var(--text-base); color: var(--text-primary); }


/* ================== CARDS ==================
   .card             - base card
   .card-header      - top section
   .card-body        - content
   .card-footer      - bottom section
   ============================================ */

.card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
}
.card-interactive:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
}
.card-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    line-height: var(--leading-snug);
}
.card-title i { color: var(--lh-gold-dark); margin-right: var(--space-2); }

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

.card-footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-sunken);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ================== BADGES & PILLS ================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    line-height: 1.4;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.badge-navy    { background: var(--color-primary-subtle); color: var(--lh-navy); }
.badge-gold    { background: var(--color-action-subtle); color: var(--lh-gold-deeper); }
.badge-info    { background: var(--color-info-subtle); color: var(--color-info-hover); }
.badge-success { background: var(--color-success-subtle); color: var(--color-success-hover); }
.badge-warning { background: var(--color-warning-subtle); color: var(--color-warning-hover); }
.badge-urgent  { background: var(--color-urgent-subtle); color: var(--color-urgent-hover); }
.badge-muted   { background: var(--surface-sunken); color: var(--text-muted); }

.badge-solid-navy    { background: var(--color-primary); color: var(--color-on-primary); }
.badge-solid-gold    { background: var(--color-action); color: var(--color-on-action); }
.badge-solid-success { background: var(--color-success); color: var(--color-on-success); }
.badge-solid-urgent  { background: var(--color-urgent); color: var(--color-on-urgent); }

.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: var(--space-1);
}
.dot-success { background: var(--color-success); }
.dot-warning { background: var(--color-warning); }
.dot-urgent  { background: var(--color-urgent); }
.dot-muted   { background: var(--text-disabled); }


/* ================== ALERTS / INLINE MESSAGES ================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-left: 4px solid transparent;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
}
.alert-icon { font-size: 1.25rem; flex-shrink: 0; line-height: 1.2; margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: var(--weight-semibold); margin-bottom: 2px; }

.alert-info    { background: var(--color-info-subtle);    border-left-color: var(--color-info);    color: var(--text-primary); }
.alert-info    .alert-icon { color: var(--color-info); }

.alert-warning { background: var(--color-warning-subtle); border-left-color: var(--color-warning); color: var(--text-primary); }
.alert-warning .alert-icon { color: var(--color-warning); }

.alert-urgent  { background: var(--color-urgent-subtle);  border-left-color: var(--color-urgent);  color: var(--text-primary); }
.alert-urgent  .alert-icon { color: var(--color-urgent); }

.alert-success { background: var(--color-success-subtle); border-left-color: var(--color-success); color: var(--text-primary); }
.alert-success .alert-icon { color: var(--color-success); }


/* ================== TABLES ================== */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--surface-card);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.table thead th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--text-muted);
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}
.table tbody td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-card-hover); }
.table-compact thead th, .table-compact tbody td { padding: var(--space-2) var(--space-3); }


/* ================== MODAL ================== */

.modal-backdrop {
    position: fixed; inset: 0;
    background: var(--surface-overlay);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-out);
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--surface-raised);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - var(--space-8));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--duration-normal) var(--ease-spring);
}
.modal-backdrop.show .modal { transform: scale(1) translateY(0); }
.modal-lg { max-width: 760px; }
.modal-sm { max-width: 380px; }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
}
.modal-title { font-size: var(--text-xl); font-weight: var(--weight-bold); }
.modal-close {
    background: transparent; border: 0;
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
}
.modal-close:hover { background: var(--surface-sunken); color: var(--text-primary); }

.modal-body { padding: var(--space-5); overflow-y: auto; flex: 1; }

.modal-footer {
    display: flex; justify-content: flex-end; gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-sunken);
}


/* ================== TOASTS ================== */

.toast-stack {
    position: fixed;
    bottom: var(--space-6); right: var(--space-6);
    z-index: var(--z-toast);
    display: flex; flex-direction: column; gap: var(--space-3);
    pointer-events: none;
    max-width: 400px;
}
.toast {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--color-info);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    font-size: var(--text-sm);
    pointer-events: auto;
    animation: toast-in var(--duration-normal) var(--ease-spring);
}
.toast.toast-success { border-left-color: var(--color-success); }
.toast.toast-warning { border-left-color: var(--color-warning); }
.toast.toast-urgent  { border-left-color: var(--color-urgent); }
.toast-icon { font-size: 1.25rem; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--color-success); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-urgent  .toast-icon { color: var(--color-urgent); }
.toast-info    .toast-icon { color: var(--color-info); }
.toast-body { flex: 1; }
.toast-close {
    background: transparent; border: 0;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    line-height: 1;
}
.toast-close:hover { background: var(--surface-sunken); }

@keyframes toast-in {
    from { transform: translateX(40px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}


/* ================== EMPTY / LOADING / SKELETON ================== */

.empty-state {
    text-align: center;
    padding: var(--space-10) var(--space-6);
    color: var(--text-muted);
}
.empty-state-icon {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 64px; height: 64px;
    margin-bottom: var(--space-4);
    border-radius: var(--radius-full);
    background: var(--surface-sunken);
    color: var(--text-muted);
    font-size: 1.75rem;
}
.empty-state-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--text-primary); margin-bottom: var(--space-2); }
.empty-state-description { font-size: var(--text-sm); line-height: var(--leading-relaxed); margin-bottom: var(--space-5); }

.skeleton {
    display: inline-block;
    background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--surface-card-hover) 50%, var(--surface-sunken) 100%);
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2.5px solid var(--border-default);
    border-top-color: var(--color-action);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================== DIVIDERS ================== */

.divider {
    border: 0;
    border-top: 1px solid var(--border-subtle);
    margin: var(--space-6) 0;
}
.divider-text {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    margin: var(--space-6) 0;
}
.divider-text::before,
.divider-text::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border-subtle);
}


/* ================== LOGO COMPONENT ================== */

.lh-logo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
}
.lh-logo-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}
.lh-logo-icon svg { width: 100%; height: 100%; }
.lh-logo-sm .lh-logo-icon { width: 32px; height: 32px; }
.lh-logo-lg .lh-logo-icon { width: 56px; height: 56px; }
.lh-logo-xl .lh-logo-icon { width: 80px; height: 80px; }

.lh-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.lh-logo-text-en {
    font-size: var(--text-md);
    font-weight: var(--weight-bold);
    color: var(--lh-navy);
    letter-spacing: 0.01em;
}
.lh-logo-text-app {
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: var(--lh-gold-dark);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
}
[data-theme="dark"] .lh-logo-text-en { color: var(--text-primary); }
