/* Rimesoft Core Design System
 *
 * Shared tokens and base components for all apps.
 * App-specific themes should build on top of these variables/classes.
 */

:root {
    /* Color palette */
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --accent-color: #0ea5e9;

    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;

    --border-color: #e2e8f0;

    /* Shadows */
    --shadow-sm: 0 1px 3px 0 rgb(15 23 42 / 0.08);
    --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.15);
    --shadow-lg: 0 10px 25px -5px rgb(15 23 42 / 0.35);

    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Shared RimeSuite shell */
    --rs-shell-bg: #101827;
    --rs-shell-bg-strong: #0b1220;
    --rs-shell-text: #ffffff;
    --rs-shell-muted: rgba(255, 255, 255, 0.68);
    --rs-shell-border: rgba(255, 255, 255, 0.18);
    --rs-shell-accent: #0f766e;
    --rs-shell-accent-hover: #0d9488;
    --rs-shell-warning: #facc15;
    --rs-shell-danger: #f87171;
}

/* Base reset / typography – intentionally minimal to avoid surprises */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
        "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

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

a:hover {
    color: var(--primary-dark);
}

/* Shared RimeSuite application shell */

.rs-suite-topbar {
    min-height: 58px;
    background: var(--rs-shell-bg);
    color: var(--rs-shell-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 24px;
    box-shadow: 0 1px 6px rgba(15, 23, 42, 0.18);
}

.rs-suite-topbar-left,
.rs-suite-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.rs-suite-topbar-right {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.rs-suite-home {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--rs-shell-muted);
    text-decoration: none;
    line-height: 1;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.rs-suite-home:hover {
    color: var(--rs-shell-text);
    text-decoration: none;
}

.rs-suite-home img {
    display: block;
    height: 30px;
    width: auto;
}

.rs-suite-home-caption {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.rs-suite-topbar-divider {
    display: block;
    width: 1px;
    height: 28px;
    background: var(--rs-shell-border);
}

.rs-suite-product-link,
.rs-suite-product-link:hover {
    display: inline-flex;
    flex-direction: column;
    color: var(--rs-shell-text);
    text-decoration: none;
    min-width: 0;
}

.rs-suite-product-name {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.08;
    white-space: nowrap;
}

.rs-suite-product-subtitle {
    color: var(--rs-shell-muted);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
}

.rs-suite-credit-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 34px;
    padding: 0 9px;
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.rs-suite-credit-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--rs-shell-text);
    text-decoration: none;
}

.rs-suite-credit-link.is-low {
    color: var(--rs-shell-warning);
}

.rs-suite-credit-link.is-empty {
    color: var(--rs-shell-danger);
}

.rs-suite-credit-icon {
    font-size: 1rem;
    line-height: 1;
}

.rs-suite-lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.rs-suite-lang-link,
.rs-suite-lang-link:hover {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 28px;
    border-radius: 999px;
    color: var(--rs-shell-muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-decoration: none;
}

.rs-suite-lang-link.active,
.rs-suite-lang-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--rs-shell-text);
}

.rs-suite-user-menu {
    min-width: 0;
}

.rs-suite-user-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(42vw, 280px);
    min-height: 36px;
    padding: 4px 9px 4px 5px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--rs-shell-text);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.rs-suite-user-button:hover,
.rs-suite-user-button:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
    outline: none;
}

.rs-suite-user-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--rs-shell-accent);
    color: #fff;
    font-size: 0.76rem;
    font-weight: 900;
    flex: 0 0 auto;
}

.rs-suite-user-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rs-suite-user-caret {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: 0.72;
    flex: 0 0 auto;
}

.rs-suite-user-dropdown {
    min-width: 220px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.18);
    overflow: hidden;
}

.rs-suite-user-menu:focus-within .rs-suite-user-dropdown,
.rs-suite-user-menu:hover .rs-suite-user-dropdown {
    display: block;
}

.rs-suite-user-dropdown .dropdown-item {
    font-size: 0.9rem;
    font-weight: 700;
    padding: 10px 14px;
}

.rs-suite-user-lang-row {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
}

.rs-suite-user-lang-link,
.rs-suite-user-lang-link:hover {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 900;
    text-decoration: none;
}

.rs-suite-user-lang-link.active,
.rs-suite-user-lang-link:hover {
    background: var(--rs-shell-accent);
    color: #fff;
}

.rs-suite-logout-button {
    width: 100%;
    text-align: left;
}

.rs-suite-login {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.rs-suite-login:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-decoration: none;
}

.rs-suite-subnav {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

.rs-suite-subnav-inner {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    overflow: visible;
}

.rs-suite-subnav-link {
    display: inline-flex;
    align-items: center;
    padding: 12px 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.92rem;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.rs-suite-subnav-link.active,
.rs-suite-subnav-link:hover {
    color: var(--rs-shell-accent);
    border-bottom-color: var(--rs-shell-accent);
    text-decoration: none;
}

.rs-suite-subnav-menu {
    position: relative;
    display: inline-flex;
}

.rs-suite-subnav-button {
    background: transparent;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    cursor: pointer;
    font-family: inherit;
}

.rs-suite-subnav-caret {
    margin-left: 6px;
    font-size: 0.72rem;
}

.rs-suite-subnav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 20;
    min-width: 210px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    display: none;
}

.rs-suite-subnav-menu:hover .rs-suite-subnav-dropdown,
.rs-suite-subnav-menu:focus-within .rs-suite-subnav-dropdown {
    display: block;
}

.rs-suite-subnav-dropdown-link {
    display: block;
    padding: 9px 10px;
    color: var(--text-secondary);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
}

.rs-suite-subnav-dropdown-header {
    display: block;
    padding: 9px 10px 5px;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    white-space: nowrap;
}

.rs-suite-subnav-dropdown-link.active,
.rs-suite-subnav-dropdown-link:hover {
    background: #ecfdf5;
    color: var(--rs-shell-accent);
    text-decoration: none;
}

@media (max-width: 720px) {
    .rs-suite-topbar {
        align-items: flex-start;
        padding: 8px 12px;
    }

    .rs-suite-topbar-left {
        gap: 9px;
    }

    .rs-suite-topbar-right {
        gap: 6px;
    }

    .rs-suite-home-caption,
    .rs-suite-product-subtitle {
        display: none;
    }

    .rs-suite-user-name {
        max-width: 120px;
    }

    .rs-suite-subnav-inner {
        padding: 0 12px;
        flex-wrap: nowrap;
        overflow-x: auto;
    }
}

/* Layout primitives */

.rs-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.rs-page-main {
    flex: 1 0 auto;
}

.rs-page-footer {
    flex-shrink: 0;
}

.rs-container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

@media (max-width: 576px) {
    .rs-container {
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }
}

.rs-section {
    padding-top: var(--space-10);
    padding-bottom: var(--space-10);
}

/* Cards */

.rs-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

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

.rs-card-header {
    margin-bottom: var(--space-4);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.rs-card-subtitle {
    margin-top: var(--space-1);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Buttons */

.rs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    padding: 0.55rem 1.2rem;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.2;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
    text-decoration: none;
}

.rs-btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.3);
}

.rs-btn-primary:hover {
    box-shadow: 0 10px 30px rgba(37, 99, 235, 0.45);
    transform: translateY(-1px);
}

.rs-btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border-color: rgba(37, 99, 235, 0.35);
}

.rs-btn-outline:hover {
    background-color: rgba(37, 99, 235, 0.06);
    border-color: rgba(37, 99, 235, 0.6);
}

.rs-btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
}

.rs-btn-ghost:hover {
    background-color: rgba(148, 163, 184, 0.12);
    color: var(--text-primary);
}

/* Inputs */

.rs-input,
.rs-select,
.rs-textarea {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    background-color: #ffffff;
}

.rs-input:focus,
.rs-select:focus,
.rs-textarea:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.75);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.rs-label {
    display: inline-block;
    margin-bottom: var(--space-1);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.rs-help-text {
    margin-top: 0.15rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Tables
 *
 * Shared Bootstrap table contrast defaults.
 * App themes override the color variables, so these adapt automatically.
 */

.table {
    --bs-table-color: var(--text-primary);
    --bs-table-color-type: var(--text-primary);
    --bs-table-color-state: var(--text-primary);
    --bs-table-bg: var(--bg-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-color: var(--text-primary);
    --bs-table-striped-bg: color-mix(in srgb, var(--bg-primary) 92%, #ffffff 8%);
    --bs-table-hover-color: var(--text-primary);
    --bs-table-hover-bg: color-mix(in srgb, var(--bg-primary) 78%, var(--bg-secondary) 22%);
    --bs-table-active-color: var(--text-primary);
    --bs-table-active-bg: color-mix(in srgb, var(--bg-primary) 70%, var(--bg-secondary) 30%);
    color: var(--text-primary);
}

.table > :not(caption) > * > * {
    color: var(--text-primary) !important;
    border-color: var(--border-color);
}

.table thead th,
.table thead td,
.table tbody th,
.table tbody td,
.table tfoot th,
.table tfoot td {
    color: var(--text-primary) !important;
}

.table a:not(.btn):not(.badge),
.table .link-primary,
.table .link-secondary {
    color: var(--text-primary) !important;
}

.table a:not(.btn):not(.badge):hover,
.table .link-primary:hover,
.table .link-secondary:hover {
    color: var(--accent-color);
}

.table .text-muted,
.table small,
.grid-view .summary,
.table-responsive + .summary {
    color: var(--text-secondary) !important;
}

/* Utility text colors */

.rs-text-muted {
    color: var(--text-muted);
}

.rs-text-secondary {
    color: var(--text-secondary);
}

/* Simple tag/chip */

.rs-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: rgba(37, 99, 235, 0.06);
    color: var(--primary-color);
}
