/* HydroPress Shared UI/UX Theme & Responsive System */
:root {
    --hp-primary: #17469e;
    --hp-primary-hover: #12377d;
    --hp-primary-soft: rgba(23, 70, 158, 0.08);
    --hp-surface: #ffffff;
    --hp-bg: #f4f7fb;
    --hp-border: #e2e8f0;
    --hp-text: #0f172a;
    --hp-muted: #64748b;
    --hp-radius: 0.75rem;
    --hp-shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
}

.dark {
    --hp-surface: #0e1726;
    --hp-bg: #060818;
    --hp-border: #1b2e4b;
    --hp-text: #e2e8f0;
    --hp-muted: #888ea8;
    --hp-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* Base Canvas & Typography */
html,
body {
    max-width: 100%;
    overflow-x: clip;
}

body {
    background-color: var(--hp-bg);
    color: var(--hp-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.main-container .main-content {
    min-width: 0;
    max-width: 100%;
}

.main-content .grid > * {
    min-width: 0;
    max-width: 100%;
}

/* Missing Tailwind Utility Polyfills (not compiled into Vristo style.css) */
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-2\.5 { gap: 0.625rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.z-\[100\] { z-index: 100; }
.bg-black\/50 { background-color: rgba(0, 0, 0, 0.5); }
.bg-black\/70 { background-color: rgba(0, 0, 0, 0.7); }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-5xl { max-width: 64rem; }
.bg-emerald-50 { background-color: #ecfdf5; }
.border-emerald-200 { border-color: #a7f3d0; }
.text-emerald-700 { color: #047857; }
.text-emerald-800 { color: #065f46; }
.bg-rose-50 { background-color: #fff1f2; }
.border-rose-200 { border-color: #fecdd3; }
.text-rose-600 { color: #e11d48; }
.text-rose-700 { color: #be123c; }

/* Unified Page Header Banner */
.hp-page-header {
    background: var(--hp-surface);
    border: 1px solid var(--hp-border);
    border-radius: var(--hp-radius);
    padding: 1.125rem 1.375rem;
    box-shadow: var(--hp-shadow);
    margin-bottom: 1.25rem;
}

.hp-page-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--hp-text);
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.hp-page-subtitle {
    font-size: 0.84rem;
    color: var(--hp-muted);
    margin-top: 0.25rem;
}

/* Panels & Cards */
.panel {
    background-color: var(--hp-surface);
    border: 1px solid var(--hp-border);
    border-radius: var(--hp-radius);
    box-shadow: var(--hp-shadow);
    min-width: 0;
    max-width: 100%;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.main-content .flex > *,
.main-content .space-y-6 > *,
.main-content .grid > * {
    min-width: 0;
    max-width: 100%;
}

.overflow-x-auto {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* Form Controls */
.form-input,
.form-select,
.form-textarea {
    border-radius: 0.5rem;
    border-color: #cbd5e1;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.dark .form-input,
.dark .form-select,
.dark .form-textarea {
    border-color: #1b2e4b;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--hp-primary);
    box-shadow: 0 0 0 3px rgba(23, 70, 158, 0.14);
    outline: none;
}

/* Buttons */
.btn {
    border-radius: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: transform 0.12s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-primary {
    background-color: var(--hp-primary);
    border-color: var(--hp-primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(23, 70, 158, 0.22);
}

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

/* Sidebar & Header Polish */
.sidebar {
    border-right: 1px solid var(--hp-border);
}

.sidebar .nav-item > a,
.sidebar .nav-item > button {
    border-radius: 0.55rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar .nav-item > a:hover,
.sidebar .nav-item > button:hover {
    background-color: var(--hp-primary-soft);
}

.sidebar .sub-menu a {
    border-radius: 0.45rem;
}

header {
    border-bottom: 1px solid var(--hp-border);
}

/* Scoped Modal Overlay (stays inside main content area on desktop, never covers sidebar) */
.hp-modal-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.56);
    backdrop-filter: blur(2px);
    overflow-y: auto;
}

@media (min-width: 1024px) {
    [dir="ltr"] .hp-modal-overlay { left: 260px; }
    [dir="rtl"] .hp-modal-overlay { right: 260px; }
    [dir="ltr"] .vertical.toggle-sidebar .hp-modal-overlay,
    [dir="ltr"] .horizontal .hp-modal-overlay { left: 0; }
    [dir="rtl"] .vertical.toggle-sidebar .hp-modal-overlay,
    [dir="rtl"] .horizontal .hp-modal-overlay { right: 0; }
    [dir="ltr"] .collapsible-vertical:not(.toggle-sidebar) .hp-modal-overlay { left: 70px; }
    [dir="rtl"] .collapsible-vertical:not(.toggle-sidebar) .hp-modal-overlay { right: 70px; }
}

.hp-modal-card {
    width: 100%;
    max-width: 720px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: var(--hp-surface);
    border: 1px solid var(--hp-border);
    border-radius: 0.9rem;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.24);
}

/* Modern Data Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table thead th {
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background-color: #f8fafc;
    color: #334155;
    border-bottom: 1px solid var(--hp-border);
    white-space: nowrap;
}

.dark .table-responsive table thead th {
    background-color: #172338;
    color: #cbd5e1;
    border-bottom-color: #1b2e4b;
}

.table-responsive table tbody td {
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.dark .table-responsive table tbody td {
    border-bottom-color: #1b2e4b;
}

/* Engineering Sizing Calculation Pages */
.hp-calc-section-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--hp-primary);
    background: linear-gradient(90deg, rgba(23, 70, 158, 0.09) 0%, rgba(23, 70, 158, 0.02) 100%);
    border-left: 4px solid var(--hp-primary);
    padding: 0.65rem 1rem;
    border-radius: 0 0.55rem 0.55rem 0;
    margin: 0;
}

.dark .hp-calc-section-title {
    color: #93c5fd;
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.16) 0%, rgba(59, 130, 246, 0.03) 100%);
    border-left-color: #60a5fa;
}

.hp-calc-page .panel {
    padding: 1.25rem 1.35rem;
}

.hp-calc-page form::after,
.hp-calc-page .panel::after {
    content: "";
    display: table;
    clear: both;
}

.hp-calc-page .panel h2 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--hp-primary);
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--hp-border);
    margin-bottom: 0.75rem;
}

.dark .hp-calc-page .panel h2 {
    color: #93c5fd;
}

.hp-calc-page form .col-md-6 {
    margin-bottom: 0.75rem;
}

.hp-calc-page form label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--hp-muted);
    margin-bottom: 0.35rem;
}

.hp-calc-page input[readonly],
.hp-calc-page textarea[readonly] {
    background-color: #f8fafc;
    font-weight: 600;
    color: #0f172a;
}

.dark .hp-calc-page input[readonly],
.dark .hp-calc-page textarea[readonly] {
    background-color: #131f33;
    color: #e2e8f0;
}

.hp-calc-page .flex:has(> input.form-input) {
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 639px) {
    .hp-calc-page .flex:has(> input.form-input) > input.form-input {
        flex: 1 1 100%;
    }
}

.hp-calc-page .table-responsive table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.hp-calc-page .table-responsive table th,
.hp-calc-page .table-responsive table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--hp-border);
    vertical-align: middle;
}

.hp-calc-page .table-responsive table tr:nth-child(even) td {
    background-color: rgba(248, 250, 252, 0.7);
}

.dark .hp-calc-page .table-responsive table tr:nth-child(even) td {
    background-color: rgba(23, 35, 56, 0.45);
}

.hp-calc-page .table-responsive table tr:hover td {
    background-color: rgba(23, 70, 158, 0.04);
}

.hp-calc-page .form-input,
.hp-calc-page .form-select {
    min-height: 2.35rem;
}

.hp-notes-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #d97706;
    border-radius: 0.65rem;
    padding: 1rem 1.25rem;
    color: #78350f;
}

.dark .hp-notes-box {
    background: rgba(217, 119, 6, 0.12);
    border-color: rgba(217, 119, 6, 0.35);
    color: #fde68a;
}

/* Mobile & Tablet Responsive Refinements */
@media (max-width: 1023px) {
    .hp-calc-page .table-responsive table {
        min-width: 580px;
    }
}

@media (max-width: 767px) {
    .animate__animated.p-6 {
        padding: 0.875rem !important;
    }

    .hp-page-header {
        padding: 0.9rem 1rem;
    }

    .hp-page-title {
        font-size: 1.075rem;
    }

    .panel {
        padding: 0.95rem !important;
    }

    .hp-calc-section-title {
        font-size: 0.9rem;
        padding: 0.55rem 0.75rem;
    }

    .hp-modal-overlay {
        padding: 0.5rem;
        align-items: flex-start;
    }

    .hp-modal-card {
        max-height: calc(100vh - 1rem);
        border-radius: 0.75rem;
    }
}
