/* ===============================================================================
   Rovify — Frappe v15 CSS overrides
   Brand tokens + UI polish via custom properties. No core files touched.
   =============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ---------------------------------------------------------------------------
   1. BRAND TOKENS — Light Mode
   --------------------------------------------------------------------------- */

:root,
[data-theme="light"] {
    /* -- Typography -- */
    --font-stack: "Inter", -apple-system, BlinkMacSystemFont,
        "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    --weight-regular: 400;

    /* -- Primary (white/black brand) -- */
    --btn-primary: #171717;
    --primary-color: #171717;
    --brand-color: #000000;
    --border-primary: #000000;

    /* -- Focus rings -- */
    --focus-default: 0 0 0 2px rgba(0, 0, 0, 0.15);
    --focus-brand: 0 0 0 2px rgba(0, 0, 0, 0.2);

    /* -- Checkbox & progress -- */
    --checkbox-gradient: linear-gradient(180deg, #171717 0%, #000000 100%);
    --progress-bar-bg: #171717;

    /* -- App tokens -- */
    --rvf-primary: #000000;
    --rvf-primary-hover: #171717;
    --rvf-primary-active: #262626;
    --rvf-primary-subtle: rgba(0, 0, 0, 0.04);
    --rvf-primary-light: #404040;
    --rvf-transition-fast: 0.12s ease;
    --rvf-transition: 0.18s ease;
    --rvf-transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* -- Shadows -- */
    --shadow-base: 0 0 0 1px rgba(0, 0, 0, 0.04),
                   0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 0 0 1px rgba(0, 0, 0, 0.03),
                 0 2px 4px rgba(0, 0, 0, 0.04),
                 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 0 0 1px rgba(0, 0, 0, 0.03),
                 0 4px 8px -2px rgba(0, 0, 0, 0.06),
                 0 8px 24px -4px rgba(0, 0, 0, 0.08);
    --shadow-2xl: 0 0 0 1px rgba(0, 0, 0, 0.04),
                  0 8px 16px -4px rgba(0, 0, 0, 0.08),
                  0 16px 40px -8px rgba(0, 0, 0, 0.12);

    /* -- Sidebar -- */
    --sidebar-select-color: var(--rvf-primary-subtle);
}


/* ---------------------------------------------------------------------------
   2. BRAND TOKENS — Dark Mode
   --------------------------------------------------------------------------- */

[data-theme="dark"] {
    /* -- Primary -- */
    --btn-primary: #ffffff;
    --primary-color: #ffffff;
    --brand-color: #ffffff;
    --border-primary: #ffffff;

    /* -- Focus rings -- */
    --focus-default: 0 0 0 2px rgba(255, 255, 255, 0.2);
    --focus-brand: 0 0 0 2px rgba(255, 255, 255, 0.25);

    /* -- Checkbox & Progress -- */
    --checkbox-gradient: linear-gradient(180deg, #e5e5e5 0%, #ffffff 100%);
    --progress-bar-bg: #ffffff;

    /* -- App tokens -- */
    --rvf-primary: #ffffff;
    --rvf-primary-hover: #e5e5e5;
    --rvf-primary-active: #d4d4d4;
    --rvf-primary-subtle: rgba(255, 255, 255, 0.06);
    --rvf-primary-light: #a3a3a3;

    /* -- Shadows -- */
    --shadow-base: 0 0 0 1px rgba(255, 255, 255, 0.04),
                   0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 0 0 1px rgba(255, 255, 255, 0.04),
                 0 2px 4px rgba(0, 0, 0, 0.15),
                 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.04),
                 0 4px 8px -2px rgba(0, 0, 0, 0.2),
                 0 8px 24px -4px rgba(0, 0, 0, 0.25);

    /* -- Sidebar -- */
    --sidebar-select-color: var(--rvf-primary-subtle);
}


/* ---------------------------------------------------------------------------
   3. GLOBAL POLISH
   --------------------------------------------------------------------------- */

body {
    font-family: var(--font-stack);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.003em;
}

::selection {
    background: rgba(0, 0, 0, 0.1);
    color: inherit;
}
[data-theme="dark"] ::selection {
    background: rgba(255, 255, 255, 0.15);
}

h1, h2, h3, .h1, .h2, .h3 {
    letter-spacing: -0.025em;
}
h4, h5, h6, .h4, .h5, .h6 {
    letter-spacing: -0.015em;
}


/* ---------------------------------------------------------------------------
   4. TRANSITIONS
   --------------------------------------------------------------------------- */

.btn {
    transition: background-color var(--rvf-transition-fast),
                box-shadow var(--rvf-transition-fast),
                color var(--rvf-transition-fast),
                transform 0.1s ease !important;
}

.form-control {
    transition: box-shadow var(--rvf-transition),
                border-color var(--rvf-transition),
                background-color var(--rvf-transition) !important;
}

.standard-sidebar-item {
    transition: background-color var(--rvf-transition-fast),
                color var(--rvf-transition-fast) !important;
}

.dropdown-item {
    transition: background-color 0.08s ease,
                color 0.08s ease !important;
}

.list-row {
    transition: background-color var(--rvf-transition-fast) !important;
}

.widget {
    transition: box-shadow var(--rvf-transition-smooth),
                transform var(--rvf-transition-smooth) !important;
}

.frappe-card,
.layout-main-section.frappe-card {
    transition: box-shadow var(--rvf-transition-smooth) !important;
}

a {
    transition: color var(--rvf-transition-fast);
}

.nav-link {
    transition: color var(--rvf-transition-fast),
                border-color var(--rvf-transition) !important;
}


/* ---------------------------------------------------------------------------
   5. BUTTONS
   --------------------------------------------------------------------------- */

.btn.btn-primary {
    background: linear-gradient(180deg, #171717 0%, #000000 100%);
    border: none;
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.btn.btn-primary:hover {
    background: linear-gradient(180deg, #262626 0%, #171717 100%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
    color: #fff !important;
    transform: translateY(-0.5px);
}

.btn.btn-primary:active,
.btn.btn-primary:active:focus {
    background: #262626 !important;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2) !important;
    color: #fff !important;
    transform: translateY(0);
}

.btn.btn-primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.2) !important;
}

/* -- Dark mode -- */
[data-theme="dark"] .btn.btn-primary {
    background: linear-gradient(180deg, #ffffff 0%, #e5e5e5 100%);
    color: #0a0a0a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .btn.btn-primary:hover {
    background: linear-gradient(180deg, #f5f5f5 0%, #ffffff 100%);
    color: #0a0a0a !important;
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .btn.btn-primary:active,
[data-theme="dark"] .btn.btn-primary:active:focus {
    background: #d4d4d4 !important;
    color: #0a0a0a !important;
}

/* -- Secondary buttons -- */
.btn.btn-default:hover,
.btn.btn-secondary:hover {
    transform: translateY(-0.5px);
}

.btn.btn-default:active,
.btn.btn-secondary:active {
    transform: translateY(0);
}

.btn-primary-light {
    color: var(--rvf-primary) !important;
}
.btn-primary-light:hover,
.btn-primary-light:active {
    color: var(--rvf-primary) !important;
}


/* ---------------------------------------------------------------------------
   6. FORM CONTROLS
   --------------------------------------------------------------------------- */

.form-control:focus {
    box-shadow: var(--focus-default) !important;
    border-color: var(--rvf-primary) !important;
    background-color: var(--control-bg);
}

.form-control:hover:not(:focus):not(:disabled):not([readonly]) {
    box-shadow: 0 0 0 1px var(--border-color);
}

input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 8 7' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4.00001L2.66667 5.80001L7 1.20001' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
        var(--checkbox-gradient) !important;
}

.custom-control-input:checked ~ .custom-control-label::before {
    background: var(--rvf-primary) !important;
    border-color: var(--rvf-primary) !important;
}

.custom-control-label::before {
    transition: background-color var(--rvf-transition),
                border-color var(--rvf-transition) !important;
}
.custom-control-label::after {
    transition: transform var(--rvf-transition) !important;
}

.frappe-control .link-btn {
    transition: opacity var(--rvf-transition-fast);
}

/* Control labels */
.frappe-control .control-label, .frappe-control label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}


/* ---------------------------------------------------------------------------
   7. FORM TABS
   --------------------------------------------------------------------------- */

.form-tabs .nav-link.active {
    border-bottom: 2px solid var(--rvf-primary) !important;
    color: var(--text-color) !important;
    font-weight: 600;
    margin-bottom: -1px;
}

.form-tabs .nav-link:hover:not(.active) {
    color: var(--text-color);
    background-color: var(--rvf-primary-subtle);
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

[data-theme="dark"] .form-tabs .nav-link.active {
    border-bottom-color: var(--rvf-primary) !important;
}


/* ---------------------------------------------------------------------------
   8. AWESOMEBAR
   --------------------------------------------------------------------------- */

.search-bar .awesomplete input:focus {
    box-shadow: var(--shadow-lg) !important;
}


/* ---------------------------------------------------------------------------
   9. SIDEBAR
   --------------------------------------------------------------------------- */

.standard-sidebar-item:hover:not(.selected) {
    background-color: var(--subtle-fg);
}

.sidebar-action {
    color: var(--rvf-primary) !important;
}

.standard-sidebar-item > a {
    color: var(--text-muted) !important;
    transition: color var(--rvf-transition-fast),
                background-color var(--rvf-transition-fast);
}
.standard-sidebar-item:hover > a {
    color: var(--text-color) !important;
}

.standard-sidebar-item.selected {
    background: var(--rvf-primary-subtle) !important;
    border-left: 2px solid var(--rvf-primary) !important;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}
.standard-sidebar-item.selected > a {
    color: var(--rvf-primary) !important;
    font-weight: 600 !important;
}


/* ---------------------------------------------------------------------------
   10. LIST VIEW
   --------------------------------------------------------------------------- */

.list-row:hover:not(.list-row-head) {
    background-color: var(--rvf-primary-subtle);
}

.like-active-item .like-action {
    color: var(--rvf-primary);
}


/* ---------------------------------------------------------------------------
   11. MODALS & DIALOGS
   --------------------------------------------------------------------------- */

.modal-backdrop.show {
    opacity: 0.5;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal .modal-content {
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--shadow-2xl);
    border-radius: var(--border-radius-lg);
}

[data-theme="dark"] .modal .modal-content {
    border-color: rgba(255, 255, 255, 0.06);
}

.modal .modal-header {
    border-bottom-color: var(--border-color);
}

.modal .modal-footer {
    border-top-color: var(--border-color);
}


/* ---------------------------------------------------------------------------
   12. WORKSPACE WIDGETS
   --------------------------------------------------------------------------- */

.widget-group {
    margin-bottom: 28px !important;
}

.widget-group-title {
    font-size: 17px !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
    color: var(--heading-color) !important;
    margin-bottom: 14px !important;
}

.widget.quick-list-widget-box .quick-list-item:hover {
    background-color: var(--rvf-primary-subtle);
}

.widget.links-widget-box {
    padding: 14px 16px !important;
}
.widget.links-widget-box .widget-head .widget-label .widget-title {
    font-size: 15px !important;
    font-weight: 700 !important;
    letter-spacing: -0.01em;
}

/* -- Shortcut cards -- */
.widget.shortcut-widget-box {
    border-radius: 12px !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: none !important;
    padding: 10px 14px !important;
    min-height: 44px !important;
    transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.18s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.18s ease !important;
}
.widget.shortcut-widget-box:hover {
    transform: translateY(-2px) !important;
    box-shadow: var(--shadow-lg) !important;
    border-color: var(--rvf-primary) !important;
}
.widget.shortcut-widget-box .widget-title {
    font-size: 13.5px !important;
    font-weight: 600 !important;
}

/* -- Number cards -- */
.widget.number-widget-box {
    border-radius: 14px !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: none !important;
    min-height: 120px !important;
    padding: 20px 22px !important;
    transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.18s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.widget.number-widget-box:hover {
    transform: translateY(-2px) !important;
    box-shadow: var(--shadow-lg) !important;
}
.widget.number-widget-box .widget-head .widget-title {
    font-size: 11.5px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    color: var(--text-muted) !important;
}
.number-widget .number {
    font-size: 36px !important;
    font-weight: 700 !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.025em;
    line-height: 1.1 !important;
}
.number-widget .widget-content {
    padding-top: 10px !important;
}


/* ---------------------------------------------------------------------------
   13. TOASTS
   --------------------------------------------------------------------------- */

.desk-alert {
    border-radius: var(--border-radius-lg) !important;
    box-shadow: var(--shadow-2xl) !important;
    border: 1px solid rgba(0, 0, 0, 0.04);
    animation-duration: 400ms !important;
}

[data-theme="dark"] .desk-alert {
    border-color: rgba(255, 255, 255, 0.06);
}


/* ---------------------------------------------------------------------------
   14. SCROLLBAR
   --------------------------------------------------------------------------- */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 100px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.2); }

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}


/* ---------------------------------------------------------------------------
   15. DROPDOWN MENUS
   --------------------------------------------------------------------------- */

.dropdown-menu {
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    box-shadow: var(--shadow-2xl) !important;
    border-radius: var(--border-radius-md) !important;
    animation: rvf-dropdown-in 0.15s ease;
}

[data-theme="dark"] .dropdown-menu {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.dropdown-item:active {
    background-color: var(--rvf-primary) !important;
    color: #fff !important;
}

@keyframes rvf-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* ---------------------------------------------------------------------------
   16. POPOVER
   --------------------------------------------------------------------------- */

.popover {
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    box-shadow: var(--shadow-2xl) !important;
    border-radius: var(--border-radius-lg) !important;
}

[data-theme="dark"] .popover {
    border-color: rgba(255, 255, 255, 0.06) !important;
}


/* ---------------------------------------------------------------------------
   17. PROGRESS BARS
   --------------------------------------------------------------------------- */

.progress-bar {
    transition: width var(--rvf-transition-smooth) !important;
}

.progress {
    border-radius: var(--border-radius-full);
    overflow: hidden;
}


/* ---------------------------------------------------------------------------
   18. FORM CARD & SECTIONS
   --------------------------------------------------------------------------- */

.std-form-layout > .form-layout > .form-page {
    box-shadow: none;
    border: 1px solid var(--border-color);
}

.inline-graph-bar-inner.dark {
    background-color: var(--rvf-primary) !important;
}

.document-link .badge-link:hover,
.document-link .report-link:hover {
    color: var(--rvf-primary);
}

.form-section,
.section-body {
    border-radius: 8px !important;
}

.modal-content {
    border-radius: 14px !important;
}


/* ---------------------------------------------------------------------------
   19. CHILD TABLE GRID
   --------------------------------------------------------------------------- */

.form-grid {
    border-color: var(--border-color);
}

.grid-heading-row {
    border-bottom-color: var(--border-color);
}

.editable-row .form-control:focus {
    box-shadow: inset 0 0 0 1px var(--rvf-primary) !important;
    border-color: var(--rvf-primary) !important;
}


/* ---------------------------------------------------------------------------
   20. NAVBAR
   --------------------------------------------------------------------------- */

.navbar {
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}

[data-theme="dark"] .navbar {
    background: rgba(30, 30, 30, 0.82) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
}

.navbar .navbar-brand img,
.navbar .app-logo {
    filter: none;
}

.navbar .badge {
    background: #171717 !important;
    color: #fff !important;
    font-weight: 600;
}

[data-theme="dark"] .navbar .badge {
    background: #ffffff !important;
    color: #0a0a0a !important;
}

.navbar .avatar-frame,
.navbar .avatar {
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    transition: border-color var(--rvf-transition-fast);
}
.navbar .avatar-frame:hover,
.navbar .avatar:hover {
    border-color: var(--rvf-primary);
}

[data-theme="dark"] .navbar .avatar-frame,
[data-theme="dark"] .navbar .avatar {
    border-color: rgba(255, 255, 255, 0.1);
}


/* ---------------------------------------------------------------------------
   21. THEME SWITCHER
   --------------------------------------------------------------------------- */

.theme-mode.active {
    border-color: var(--rvf-primary);
    box-shadow: 0 0 0 2px var(--rvf-primary-subtle);
}


/* ---------------------------------------------------------------------------
   22. INDICATOR PILLS
   --------------------------------------------------------------------------- */

.indicator-pill {
    border-radius: 100px !important;
    padding: 2px 10px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
}


/* ---------------------------------------------------------------------------
   23. ANIMATIONS
   --------------------------------------------------------------------------- */

@keyframes rvf-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes rvf-slide-up {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.std-form-layout > .form-layout > .form-page {
    animation: rvf-fade-in 0.2s ease;
}

.frappe-list .list-row-container {
    animation: rvf-slide-up 0.2s ease both;
}
.frappe-list .list-row-container:nth-child(1) { animation-delay: 0s; }
.frappe-list .list-row-container:nth-child(2) { animation-delay: 0.02s; }
.frappe-list .list-row-container:nth-child(3) { animation-delay: 0.04s; }
.frappe-list .list-row-container:nth-child(4) { animation-delay: 0.06s; }
.frappe-list .list-row-container:nth-child(5) { animation-delay: 0.08s; }
.frappe-list .list-row-container:nth-child(6) { animation-delay: 0.1s; }
.frappe-list .list-row-container:nth-child(7) { animation-delay: 0.12s; }
.frappe-list .list-row-container:nth-child(8) { animation-delay: 0.14s; }
.frappe-list .list-row-container:nth-child(9) { animation-delay: 0.16s; }
.frappe-list .list-row-container:nth-child(10) { animation-delay: 0.18s; }


/* ---------------------------------------------------------------------------
   24. FORM VIEW — Section headers & labels
   --------------------------------------------------------------------------- */

.form-page .section-head,
.form-page .section-head .collapse-indicator {
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--rvf-primary) !important;
}

.form-page .control-label,
.form-page .frappe-control .label-area label {
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.form-page .form-section:not(:first-child) {
    margin-top: 8px;
}
