/* Sticky Template Enhancements for Pörssäri */
/* Modern card components, forms, and UI improvements */

/* ===== CARD COMPONENTS ===== */
.card-style {
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: none;
    overflow: hidden;
    transition: all 0.3s ease;
    background: #fff;
}

.card-style:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.card-style[data-card-height="cover"] {
    position: relative;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-center {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 2rem;
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

.card-overlay.opacity-30 {
    opacity: 0.3;
}

/* ===== FORM COMPONENTS ===== */
.form-floating-over {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-floating-over .form-control {
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.form-floating-over .form-control:focus {
    border-color: #4A89DC;
    box-shadow: 0 0 0 0.2rem rgba(74, 137, 220, 0.25);
    background: #fff;
}

.form-floating-over label {
    position: absolute;
    top: 50%;
    left: 3rem;
    transform: translateY(-50%);
    color: #6c757d;
    transition: all 0.3s ease;
    pointer-events: none;
    background: #f8f9fa;
    padding: 0 0.5rem;
}

.form-floating-over .form-control:focus ~ label,
.form-floating-over .form-control:not(:placeholder-shown) ~ label {
    top: 0;
    left: 1rem;
    font-size: 0.875rem;
    color: #4A89DC;
    background: #fff;
}

.form-floating-over i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    z-index: 3;
}

.form-floating-over .form-control:focus ~ i {
    color: #4A89DC;
}

/* ===== BUTTON ENHANCEMENTS ===== */
.btn-m {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 15px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-full {
    width: 100%;
}

.btn-center-l {
    display: block;
    margin: 0 auto;
    max-width: 300px;
}

.rounded-l {
    border-radius: 15px;
}

.bg-highlight {
    background: linear-gradient(135deg, #4A89DC, #5D9CEC);
    border: none;
    color: #fff;
}

.bg-highlight:hover {
    background: linear-gradient(135deg, #3a6bb8, #4a8bd8);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(74, 137, 220, 0.3);
}

/* ===== TYPOGRAPHY ===== */
.font-40 {
    font-size: 2.5rem;
}

.font-800 {
    font-weight: 800;
}

.font-900 {
    font-weight: 900;
}

.color-black {
    color: #000;
}

.color-theme {
    color: #4A89DC;
}

/* ===== HEADER ENHANCEMENTS ===== 
.header-fixed {
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.gradient-blue {
    background: linear-gradient(135deg, #4A89DC, #5D9CEC);
}

.header-logo-app {
    padding: 1rem 1.5rem;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
}

.header-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s ease;
    text-decoration: none;
    color: #fff;
}

.header-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}
    */

/* Header fixes (active) */
:root {
    --sidebar-width: 14rem;
    --sidebar-collapsed-width: 4.5rem;
}
.gradient-blue {
    background: linear-gradient(135deg, #4A89DC, #5D9CEC);
}

@media (min-width: 768px) {
    /* Keep gradient when header is fixed on wide screens */
    .gradient-blue.header-fixed {
        background: linear-gradient(135deg, #4A89DC, #5D9CEC) !important;
        backdrop-filter: none;
        border-bottom-color: transparent;
    }
}

/* ===== FOOTER ENHANCEMENTS ===== 
.footer-bar-1 {
    background: #fff;
    border-top: 1px solid #e9ecef;
    padding: 0.75rem 0;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
}

/* Footer bar nav-link styles removed - using custom.css instead */
    */

/* ===== SIDEBAR ENHANCEMENTS ===== */
#sidebar {
    background: #fff;
    border-right: 1px solid #e9ecef;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    width: var(--sidebar-width);
    transition: all 0.3s ease;
}

#sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-toggle {
    padding: 1rem;
    color: #6c757d;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    color: #4A89DC;
    background: rgba(74, 137, 220, 0.1);
}

.nav-link {
    padding: 1rem 1.5rem;
    color: #6c757d;
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 12px;
    margin: 0.25rem 1rem;
}

.nav-link:hover,
.nav-link.active-nav {
    color: #4A89DC;
    background: rgba(74, 137, 220, 0.1);
}

/* Sidebar: remove side margins so highlight touches the left edge */
#sidebar .nav-link {
    margin-left: 0;
    margin-right: 0;
}

/* Layout tuning for sidebar + header + content on wide screens */
/* Base: mobile paddings same as desktop, margins remain 0 by default */
#content.page-content {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}
@media (min-width: 768px) {
    /* Ensure header sits flush against the sidebar without extra gap */
    .header.has-sidebar {
        margin-left: var(--sidebar-width) !important;
    }
    /* Add breathing room to content so it isn't stuck to the right edge */
    #content.page-content.has-sidebar {
        margin-left: var(--sidebar-width) !important;
    }
    /* When sidebar is collapsed, shrink margins accordingly */
    body.sidebar-collapsed .header.has-sidebar {
        margin-left: var(--sidebar-collapsed-width) !important;
    }
    body.sidebar-collapsed #content.page-content.has-sidebar {
        margin-left: var(--sidebar-collapsed-width) !important;
    }
}

.nav-link i {
    font-size: 1.5rem;
    margin-right: 1rem;
}

.sidebar-label {
    transition: all 0.3s ease;
}

#sidebar.collapsed .sidebar-label {
    opacity: 0;
    transform: translateX(-20px);
}

/* Sidebar item layout: two-column grid in expanded, centered icon in collapsed */
:root {
    --sidebar-icon-col: var(--sidebar-collapsed-width);
}

#sidebar .nav-link {
    display: grid;
    grid-template-columns: var(--sidebar-icon-col) 1fr;
    align-items: center;
    column-gap: .5rem;
    padding: 1rem 0; /* match py-3 vertical rhythm */
}

#sidebar .nav-link i {
    margin-right: 0;
    justify-self: center;
    align-self: center;
    line-height: 1; /* consistent vertical centering */
}

#sidebar .sidebar-label {
    opacity: 1;
    transform: none;
    text-align: left;
    padding-left: .5rem; /* spacing between icon and text comes from label, not icon column */
    white-space: nowrap;
    overflow: hidden;
    transition: opacity .2s ease, transform .2s ease, max-width .2s ease, padding-left .2s ease;
}

#sidebar .sidebar-label span { margin-left: 0 !important; }

#sidebar.collapsed .nav-link {
    /* Keep grid so icon column remains fixed and icon x-position is stable */
    display: grid;
    grid-template-columns: var(--sidebar-icon-col) 1fr;
    justify-items: center;
    padding: 1rem 0; /* same vertical rhythm as expanded */
}

#sidebar.collapsed .sidebar-label {
    max-width: 0;
    opacity: 0;
    transform: translateX(-8px);
    padding-left: 0;
    pointer-events: none;
}

/* ===== CHART ENHANCEMENTS ===== */
.chart-fixed-220 {
    position: relative;
    height: 220px;
    width: 100%;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 1rem;
}

.chart-fixed-220 canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* ===== LIST ENHANCEMENTS ===== */
.list-custom-small {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list-custom-small li {
    margin-bottom: 0.5rem;
}

.list-custom-small a {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    color: #495057;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    cursor: pointer;
}

.list-custom-small a:hover {
    background: rgba(74, 137, 220, 0.1);
    color: #4A89DC;
    transform: translateX(5px);
}

.list-custom-small a i {
    margin-right: 1rem;
    width: 20px;
    text-align: center;
}

.list-custom-small a i.fa-chevron-right,
.list-custom-small a .fa.fa-chevron-right,
.list-custom-small a .fas.fa-chevron-right {
    margin-left: auto;
    opacity: .55;
    font-size: 1.15rem;
}

/* Offcanvas: Estate settings list visual lift (now global via .list-custom-small a) */

/* ===== DANGER ZONE ACTIVATOR ===== */
[data-danger-zone] { position: relative; }
[data-danger-zone][data-active="false"] .dz-content {
    pointer-events: none;
    opacity: .6;
    filter: grayscale(.05);
}
.dz-activator {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.15);
    backdrop-filter: blur(1px);
    border-radius: 16px;
}
.dz-activator .dz-activate-btn {
    box-shadow: 0 8px 24px rgba(220,53,69,0.35);
}

/* ===== RESPONSIVE IMPROVEMENTS ===== */
@media (min-width: 768px) {
    .card-style {
        border-radius: 25px;
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
    }
    
    .header-fixed {
        backdrop-filter: blur(30px);
        background: rgba(255, 255, 255, 0.95);
    }
    
    .footer-bar-1 {
        display: none;
    }
}

@media (min-width: 1200px) {
    .card-style {
        border-radius: 30px;
    }
    
    .btn-m {
        padding: 1rem 2.5rem;
        font-size: 1.1rem;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.bounce-in {
    animation: bounceIn 0.6s ease-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.float {
    animation: float 3s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
}

/* Staggered animations */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

/* ===== LOGIN PAGE ENHANCEMENTS ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.login-main {
    max-width: 1200px;
    margin: 0 auto;
}

.login-row {
    min-height: 600px;
    align-items: center;
}

.login-side-image {
    background: linear-gradient(135deg, #4A89DC, #5D9CEC);
    border-radius: 20px;
    padding: 3rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
}

/* Override: show logo image instead of gradient if defined in project */
.login-side-image {
    background-image: url("/static/img/logoilmantaustaa22.png");
    background-position: center;
    background-repeat: no-repeat;
    /* Keep logo balanced across widths (desktop) */
    background-size: clamp(200px, 55%, 420px) auto;
    background-origin: content-box;
}

@media (max-width: 768px) {
    .login-side-image {
        /* Smaller logo on stacked mobile layout */
        background-size: clamp(120px, 40%, 240px) auto;
        background-origin: content-box;
        min-height: 180px;
        padding: 2rem;
        padding-top: 2.75rem; /* add a bit more space from top */
    }
}

.login-side-content {
    text-align: center;
}

.login-features {
    text-align: left;
    margin-top: 2rem;
}

.feature-item {
    display: flex;
    align-items: center;
    font-size: 1rem;
}

.login-right {
    background: white;
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.login-input-box {
    max-width: 400px;
    margin: 0 auto;
}

/* Unify login input/button rounding to match modern style */
.login-right .form-control,
.login-input-box .form-control,
.login-right .form-select,
.login-input-box .form-select {
    border-radius: 15px;
}
.login-right .btn,
.login-input-box .btn {
    border-radius: 15px;
}

.login-text-divider {
    position: relative;
    text-align: center;
    color: #6c757d;
    font-size: 0.875rem;
}

.login-text-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e9ecef;
    z-index: 1;
}

.login-text-divider span {
    background: white;
    padding: 0 1rem;
    position: relative;
    z-index: 2;
}

/* ===== UTILITY CLASSES ===== */
.opacity-60 {
    opacity: 0.6;
}

.opacity-70 {
    opacity: 0.7;
}

.shadow-s {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.text-uppercase {
    text-transform: uppercase;
}

.font-12 {
    font-size: 0.75rem;
}

.font-14 {
    font-size: 0.875rem;
}

.font-16 {
    font-size: 1rem;
}

.font-18 {
    font-size: 1.125rem;
}

.font-30 {
    font-size: 1.875rem;
}

.font-40 {
    font-size: 2.5rem;
}

.font-700 {
    font-weight: 700;
}

.font-800 {
    font-weight: 800;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mb-5 {
    margin-bottom: 3rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mt-5 {
    margin-top: 3rem;
}

.me-2 {
    margin-right: 0.5rem;
}

.me-3 {
    margin-right: 1rem;
}

.py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.px-3 {
    padding-left: 1rem;
    padding-right: 1rem;
}

.pb-3 {
    padding-bottom: 1rem;
}

.small {
    font-size: 0.875rem;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    --bs-body-bg: #1a1a1a;
    --bs-body-color: #ffffff;
    --bs-card-bg: #2d2d2d;
    --bs-border-color: #404040;
}

[data-theme="dark"] body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

[data-theme="dark"] .card-style {
    background: var(--bs-card-bg);
    border: 1px solid var(--bs-border-color);
    color: var(--bs-body-color);
}

[data-theme="dark"] .header-fixed {
    background: rgba(45, 45, 45, 0.9);
    border-bottom: 1px solid var(--bs-border-color);
}

[data-theme="dark"] #sidebar {
    background: var(--bs-card-bg);
    border-right: 1px solid var(--bs-border-color);
}

[data-theme="dark"] .footer-bar-1 {
    background: var(--bs-card-bg);
    border-top: 1px solid var(--bs-border-color);
}

[data-theme="dark"] .form-floating-over .form-control {
    background: var(--bs-card-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

[data-theme="dark"] .form-floating-over .form-control:focus {
    background: var(--bs-body-bg);
    border-color: #4A89DC;
}

[data-theme="dark"] .form-floating-over label {
    background: var(--bs-card-bg);
    color: #adb5bd;
}

[data-theme="dark"] .form-floating-over .form-control:focus ~ label {
    background: var(--bs-body-bg);
    color: #4A89DC;
}

[data-theme="dark"] .list-custom-small a {
    background: var(--bs-card-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
}

[data-theme="dark"] .list-custom-small a:hover {
    background: rgba(74, 137, 220, 0.1);
    color: #4A89DC;
}

[data-theme="dark"] .login-right {
    background: var(--bs-card-bg);
    color: var(--bs-body-color);
}

[data-theme="dark"] .login-text-divider span {
    background: var(--bs-card-bg);
}

/* ===== LOGIN DARK MODE FIXES (Sticky-style overrides) ===== */
[data-theme="dark"] .login-wrapper {
    background: linear-gradient(135deg, #121212 0%, #1b1b1b 100%);
}

[data-theme="dark"] .login-side-image {
    /* Keep logo, remove bright panels behind it */
    background-color: transparent;
}

[data-theme="dark"] .login-text-divider {
    color: #adb5bd;
}

[data-theme="dark"] .login-text-divider::before {
    background: var(--bs-border-color);
}

[data-theme="dark"] .login-right {
    background: var(--bs-card-bg);
    border: 1px solid var(--bs-border-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.35);
}

[data-theme="dark"] .login-right .form-control,
[data-theme="dark"] .login-input-box .form-control,
[data-theme="dark"] .login-right .form-select,
[data-theme="dark"] .login-input-box .form-select {
    background: var(--bs-card-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

[data-theme="dark"] .login-right .form-control::placeholder,
[data-theme="dark"] .login-input-box .form-control::placeholder {
    color: #adb5bd;
    opacity: 0.7;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--bs-card-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.theme-toggle i {
    font-size: 1.2rem;
    color: var(--bs-body-color);
}

/* ===== PRELOADER ===== */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bs-body-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

#preloader.preloader-hide {
    opacity: 0;
    pointer-events: none;
}

.spinner-border.color-highlight {
    color: #4A89DC;
    width: 3rem;
    height: 3rem;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
/* Lazy loading for images */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[data-src].loaded {
    opacity: 1;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    margin-bottom: 0;
    width: 60%;
}

.skeleton-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
    border-radius: 15px;
}

/* Critical CSS inlining */
.critical-css {
    display: none;
}

/* Preload critical resources */
.preload-critical {
    font-display: swap;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== OFFLINE/ONLINE MESSAGES ===== */
.offline-message,
.online-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 2rem;
    border-radius: 25px;
    font-weight: 600;
    z-index: 9998;
    display: none;
}

/* Ensure Bootstrap modals appear above offcanvas/backdrops */
.modal-backdrop {
    z-index: 12000 !important;
}
.modal {
    z-index: 12010 !important;
}

.bg-red-dark {
    background: #dc3545;
}

.bg-green-dark {
    background: #198754;
}

.color-white {
    color: #fff;
}
