/* Clarity Eco UI Theme */
:root {
    --app-primary: #00a89e;
    --app-primary-dark: #008d85;
    --app-accent: #9ac33c;
    --app-accent-dark: #82a532;
    --app-ink: #0f172a;
    --app-muted: #64748b;
    --app-surface: #f8fafc;
    --app-surface-strong: #ffffff;
    --app-card-radius: 16px;
    --app-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --app-shadow-md: 0 10px 24px rgba(15, 23, 42, 0.08);
    --app-shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.1);
    --app-navbar-bg: rgba(255, 255, 255, 0.96);
}

/* Global Styles */
body {
    background-color: #f4f7f6;
    font-family: 'Inter', sans-serif;
    color: #333;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

body.loaded {
    opacity: 1;
}

/* Preloader Styles */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#preloader.loaded {
    opacity: 0;
    visibility: hidden;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--app-primary);
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

/* Dashboard Layout Optimizations */
.dashboard-title-upper {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.welcome-header {
    background: linear-gradient(135deg, rgba(255,255,255,0.8), rgba(255,255,255,0.4));
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 1.5rem;
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    margin-bottom: 2rem;
    animation: fadeInDown 0.8s ease-out;
}

/* Advanced Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-stagger > * {
    opacity: 0;
}

.animate-stagger-1 { animation: fadeInUp 0.5s ease-out forwards; animation-delay: 0.1s; }
.animate-stagger-2 { animation: fadeInUp 0.5s ease-out forwards; animation-delay: 0.2s; }
.animate-stagger-3 { animation: fadeInUp 0.5s ease-out forwards; animation-delay: 0.3s; }
.animate-stagger-4 { animation: fadeInUp 0.5s ease-out forwards; animation-delay: 0.4s; }
.animate-stagger-5 { animation: fadeInUp 0.5s ease-out forwards; animation-delay: 0.5s; }

/* Enhanced Hover Effects */
.card-dashboard {
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease !important;
}

.card-dashboard:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 20px rgba(0,0,0,0.1) !important;
    border-color: var(--app-primary) !important;
}

/* Table Enhancements */
.table-app thead th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: var(--app-secondary);
    border-bottom: 2px solid rgba(0,0,0,0.05);
}

.table-app tbody tr:hover {
    background-color: rgba(0, 168, 158, 0.03);
}

/* SVG Icon Wrapper */
.svg-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--app-gradient);
    color: white;
    margin-right: 1rem;
    box-shadow: 0 4px 15px rgba(0, 168, 158, 0.2);
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

html,
body {
    background-color: var(--app-surface);
    color: var(--app-ink);
}

.main-content .page-content {
    padding-bottom: 2rem;
}

/* Header / Navbar */
.header {
    position: relative;
    z-index: 1030;
}

.header .navbar {
    background: linear-gradient(135deg, var(--app-primary) 0%, var(--app-primary-dark) 55%, var(--app-accent) 100%) !important;
    box-shadow: var(--app-shadow-md);
    position: relative;
    z-index: 1031;
}

.header .navbar-brand {
    font-weight: 700;
}

.app-navbar {
    background: linear-gradient(135deg, #00a89e 0%, #008d85 100%);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: 70px;
    display: flex;
    align-items: center;
}

.app-navbar .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem !important;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.app-navbar .nav-link:hover, .app-navbar .nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff !important;
}

/* Quick Action Button */
.quick-action-btn {
    background: #9ac33c !important;
    color: #fff !important;
    border-radius: 12px !important;
    padding: 0.5rem 1.25rem !important;
    box-shadow: 0 4px 12px rgba(154, 195, 60, 0.3);
    font-weight: 600 !important;
}

.quick-action-btn:hover {
    background: #82a532 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(154, 195, 60, 0.4);
}

.icon-box {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.bg-primary-soft { background-color: rgba(0, 168, 158, 0.1) !important; }
.bg-success-soft { background-color: rgba(154, 195, 60, 0.1) !important; }
.bg-info-soft { background-color: rgba(13, 202, 240, 0.1) !important; }
.bg-warning-soft { background-color: rgba(255, 193, 7, 0.1) !important; }
.bg-danger-soft { background-color: rgba(220, 53, 69, 0.1) !important; }

/* Glassmorphism Cards */
.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: var(--app-shadow-md);
    border-radius: var(--app-card-radius);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.avatar-md {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.bg-light-hover:hover {
    background-color: rgba(0, 0, 0, 0.03) !important;
}

.transition-all {
    transition: all 0.3s ease;
}

.letter-spacing {
    letter-spacing: 0.05em;
}

.smaller {
    font-size: 0.85rem;
}

.btn-xs {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

.header .logo-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--app-shadow-sm);
}

.header .logo-img {
    height: 46px;
}

.header .nav-link {
    border-radius: 10px;
    transition: all 0.2s ease;
}

.header .nav-link:hover,
.header .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
}

.header .dropdown-menu {
    border: 0;
    border-radius: 14px;
    box-shadow: var(--app-shadow-lg);
    z-index: 2140;
}

.header .dropdown-menu-xl {
    min-width: 800px;
}

.header .dropdown-menu-lg {
    min-width: 700px;
}

.header .dropdown-menu-md {
    min-width: 550px;
}

.header .dropdown-menu .dropdown-header {
    font-weight: 700;
    color: #334155;
}

.header .dropdown-item {
    border-radius: 8px;
    margin: 2px 0;
}

.header .dropdown-item:hover {
    background: rgba(0, 183, 198, 0.08);
}

.header .avatar-sm {
    width: 32px;
    height: 32px;
}

.header .avatar-title {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.header .breadcrumb {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.header .breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: #6c757d;
}

.header .breadcrumb-item a {
    color: #6c757d;
}

.header .breadcrumb-item a:hover {
    color: var(--app-primary);
}

.header .breadcrumb-item.active {
    color: var(--app-primary);
    font-weight: 500;
}

.header .badge {
    font-size: 0.6rem;
    padding: 0.25em 0.4em;
}

.header .filial-selector {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0.25rem 0.75rem;
    color: #fff;
    text-decoration: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.header .filial-selector:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.header .badge-matriz {
    background-color: #ffc107;
    color: #000;
}

.header .badge-filial {
    background-color: #17a2b8;
    color: #fff;
}

.header .badge-master {
    background-color: #dc3545;
    color: #fff;
}

.header .filial-info {
    font-size: 0.8rem;
    opacity: 0.95;
}

/* Buttons */
.btn-app-primary,
.btn-primary {
    background: linear-gradient(135deg, var(--app-primary), var(--app-primary-dark));
    border: none;
    color: #fff;
    border-radius: 10px;
    font-weight: 600;
}

.btn-app-primary:hover,
.btn-primary:hover {
    color: #fff;
    filter: brightness(1.05);
}

.btn-outline-secondary {
    border-radius: 10px;
}

/* Cards and tables */
.card,
.card-custom,
.card-form,
.dashboard-card-app {
    border: none;
    border-radius: var(--app-card-radius);
    box-shadow: var(--app-shadow-sm);
}

.card-header-custom {
    background: linear-gradient(135deg, var(--app-primary), var(--app-primary-dark));
    color: #fff;
    border-radius: var(--app-card-radius) var(--app-card-radius) 0 0 !important;
}

.app-toolbar-sticky {
    position: sticky;
    top: 0;
    z-index: 1010;
    background: linear-gradient(to bottom, var(--app-surface) 72%, transparent);
    padding-bottom: 0.5rem;
}

.table-app,
.table-custom,
.table-dashboard {
    font-size: 0.9rem;
    vertical-align: middle;
}

.table-app thead th,
.table-custom thead th,
.table-dashboard thead th {
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: 0.76rem;
    color: var(--app-muted);
    border-bottom: 2px solid #dbe4ea;
    text-transform: uppercase;
    background: #fff;
}

.table-app tbody tr,
.table-custom tbody tr,
.table-dashboard tbody tr {
    transition: background 0.15s ease;
}

.table-app tbody tr:hover,
.table-custom tbody tr:hover,
.table-dashboard tbody tr:hover {
    background-color: rgba(0, 183, 198, 0.05);
}

.stats-card {
    border-radius: 14px;
    box-shadow: var(--app-shadow-md);
}

.stats-card.stats-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stats-card.stats-tertiary {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stats-card.stats-quaternary {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.dashboard-card-app:hover {
    transform: translateY(-2px);
    box-shadow: var(--app-shadow-md);
}

/* Login */
.login-page {
    min-height: 100vh;
    background:
        radial-gradient(1200px 500px at -10% -20%, rgba(0, 183, 198, 0.32), transparent),
        radial-gradient(900px 460px at 120% 120%, rgba(166, 206, 57, 0.35), transparent),
        linear-gradient(145deg, #0f2533, #1b3344);
}

.login-shell {
    border-radius: 20px;
    box-shadow: 0 26px 52px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.login-brand {
    background: linear-gradient(145deg, rgba(0, 183, 198, 0.95), rgba(166, 206, 57, 0.92));
    color: #fff;
}

.login-brand .logo {
    max-width: 240px;
    width: 100%;
    height: auto;
    border-radius: 14px;
    background: #fff;
    padding: 12px;
}

.login-form .form-control {
    border-radius: 12px;
    border: 1px solid #d6dee5;
    padding: 0.72rem 0.95rem;
}

.login-form .form-control:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 0.22rem rgba(0, 183, 198, 0.18);
}

/* Cadastro cliente tabs */
.nav-cliente-cadastro .nav-link {
    border-radius: 10px;
    margin-right: 0.35rem;
    color: #64748b;
    font-weight: 500;
}

.nav-cliente-cadastro .nav-link.active {
    background: linear-gradient(135deg, var(--app-primary), var(--app-primary-dark)) !important;
    color: #fff !important;
}

.cliente-submit-sticky {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: linear-gradient(to top, var(--app-surface) 60%, transparent);
    padding-top: 1rem;
    margin-top: 1rem;
}

/* Overlay (form-submit-ui.js) */
#app-form-loading-overlay.flex-visible {
    display: flex !important;
}

#app-form-loading-overlay .app-form-loading-inner {
    text-align: center;
    padding: 2rem;
}

@media (max-width: 991.98px) {
    .header .logo-img {
        height: 40px;
    }

    .login-brand {
        text-align: center;
    }

    .header .navbar-collapse {
        background: rgba(8, 34, 48, 0.94);
        border-radius: 12px;
        padding: 0.75rem;
        margin-top: 0.75rem;
        max-height: 78vh;
        overflow: auto;
    }

    .header .dropdown-menu,
    .header .dropdown-menu-xl,
    .header .dropdown-menu-lg,
    .header .dropdown-menu-md {
        min-width: 100% !important;
        width: 100%;
        border-radius: 10px;
        margin-top: 0.4rem;
        box-shadow: none;
    }

    .header .js-mobile-sections .dropdown-header {
        border-radius: 8px;
        margin: 0.25rem 0;
        padding: 0.65rem 0.9rem !important;
        cursor: pointer;
        position: relative;
    }

    .header .js-mobile-sections .dropdown-header.app-mobile-section-toggle::after {
        content: "\F282";
        font-family: bootstrap-icons;
        position: absolute;
        right: 0.85rem;
        top: 50%;
        transform: translateY(-50%);
        opacity: 0.8;
        transition: transform 0.2s ease;
    }

    .header .js-mobile-sections .dropdown-header[aria-expanded="true"]::after {
        transform: translateY(-50%) rotate(180deg);
    }

    .header .js-mobile-sections .app-mobile-section-content {
        display: none;
        padding: 0.35rem 0.55rem 0.55rem;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.95);
    }

    .header .js-mobile-sections .app-mobile-section-content.is-open {
        display: block;
    }

    .header .border-end {
        border-right: none !important;
        border-bottom: 1px solid #e2e8f0 !important;
    }

    .header .navbar-nav {
        padding: 0.5rem 0;
    }

    .header .nav-link {
        margin: 2px 0;
    }

    .header .filial-selector {
        margin-top: 10px;
        justify-content: center;
    }

    /* Compactação dos menus de utilidades no mobile */
    .header #navbarNotificacoes + .dropdown-menu {
        width: min(92vw, 320px) !important;
        max-width: 92vw !important;
    }

    .header #navbarNotificacoes + .dropdown-menu .dropdown-header {
        padding: 0.6rem 0.75rem !important;
        font-size: 0.85rem;
    }

    .header #navbarNotificacoes + .dropdown-menu .dropdown-item {
        padding: 0.55rem 0.7rem;
        margin: 0;
    }

    .header #navbarNotificacoes + .dropdown-menu .dropdown-item p.small {
        font-size: 0.76rem;
        margin-bottom: 0.2rem !important;
    }

    .header #navbarNotificacoes + .dropdown-menu .dropdown-item .small.text-muted,
    .header #navbarNotificacoes + .dropdown-menu .dropdown-item small.text-muted {
        font-size: 0.7rem;
    }

    .header #navbarNotificacoes + .dropdown-menu .btn {
        padding: 0.28rem 0.45rem;
        font-size: 0.75rem;
    }

    .header #navbarUsuario + .dropdown-menu {
        width: min(92vw, 280px) !important;
        max-width: 92vw !important;
    }

    .header #navbarUsuario + .dropdown-menu .dropdown-item {
        padding: 0.55rem 0.7rem;
    }

    .header #navbarUsuario .avatar-sm {
        width: 28px;
        height: 28px;
    }

    .header #navbarUsuario .badge {
        font-size: 0.55rem;
    }
}

}

/* Dashboard Utilities */
.quick-action-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.quick-action-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 1) !important;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1) !important;
}

.unit-card {
    transition: all 0.25s ease;
}

.unit-card:hover {
    border-color: var(--app-primary) !important;
    background: var(--app-primary-soft) !important;
    transform: scale(1.02);
}

.bg-primary-soft { background-color: rgba(59, 125, 221, 0.1) !important; }
.bg-success-soft { background-color: rgba(28, 187, 140, 0.1) !important; }
.bg-warning-soft { background-color: rgba(252, 185, 44, 0.1) !important; }
.bg-danger-soft { background-color: rgba(252, 91, 111, 0.1) !important; }
.bg-info-soft { background-color: rgba(79, 198, 225, 0.1) !important; }

.letter-spacing { letter-spacing: 0.05em; }
.smaller { font-size: 0.75rem; }

@media (max-width: 767.98px) {
    .header .navbar-brand span {
        font-size: 1rem;
    }
}
