/* DESIGN SYSTEM - SAAS PORTAL */

:root {
    --bg-dark: #0a0e17;
    --bg-deep: #06090f;
    --bg-panel: rgba(20, 30, 54, 0.45);
    --bg-input: rgba(13, 20, 38, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.5);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #6366f1; /* Indigo */
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.35);
    
    --secondary: #8b5cf6; /* Violet/Purple */
    --secondary-hover: #7c3aed;
    --secondary-glow: rgba(139, 92, 246, 0.35);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    
    --danger: #f43f5e;
    --danger-hover: #e11d48;
    --danger-glow: rgba(244, 63, 94, 0.2);
    
    --warning: #f59e0b;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

/* BACKDROP GLOW EFFECTS */
.glow-bg {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.12;
    z-index: -1;
    pointer-events: none;
}
.glow-purple {
    background: var(--secondary);
    top: -200px;
    right: -100px;
}
.glow-blue {
    background: var(--primary);
    bottom: -200px;
    left: -100px;
}

/* GLASSMORPHISM UTILITY */
.glass {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.4);
}

/* UTILITIES */
.hidden { display: none !important; }
.space-y-4 > * + * { margin-top: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.text-center { text-align: center; }
.justify-center { justify-content: center; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.text-gray-450 { color: #a5b4fc; }
.text-gray-400 { color: var(--text-secondary); }
.text-gray-500 { color: var(--text-muted); }
.text-xs { font-size: 0.75rem; }
.font-semibold { font-weight: 600; }
.inline-block { display: inline-block; }

/* LAYOUT LOGIN */
.login-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 440px;
    border-radius: 24px;
    padding: 40px;
    transform: translateY(0);
    transition: var(--transition);
}
.login-container:hover {
    box-shadow: 0 15px 40px 0 rgba(99, 102, 241, 0.15);
}

.login-header {
    text-align: center;
    margin-bottom: 35px;
}
.logo-icon-wrap {
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    box-shadow: 0 8px 20px 0 var(--primary-glow);
}
.logo-svg {
    color: #fff;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
.login-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(to right, #fff, #c7d2fe);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* FORM CONTROLS */
.input-field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.input-field-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: var(--transition);
}
.input-wrapper input, .input-field-group select, .input-field-group input[type="text"], .input-field-group input[type="email"], .input-field-group input[type="password"] {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px 14px 44px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}
.input-field-group select {
    padding-left: 16px; /* dropdown selects dont have icons */
}
.input-wrapper input:focus, .input-field-group select:focus, .input-field-group input[type="text"]:focus, .input-field-group input[type="email"]:focus, .input-field-group input[type="password"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background-color: rgba(13, 20, 38, 0.85);
}
.input-wrapper input:focus + .input-icon {
    color: var(--primary);
}

.alert-box {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.4;
    font-weight: 500;
}
.alert-box.error {
    background-color: rgba(244, 63, 94, 0.15);
    border: 1px solid var(--danger);
    color: #fda4af;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    padding: 14px 24px;
    transition: var(--transition);
    text-decoration: none;
}
.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 8px;
}
.btn-block {
    display: flex;
    width: 100%;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 4px 14px 0 var(--primary-glow);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 var(--primary-glow);
    filter: brightness(1.1);
}
.btn-secondary {
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.12);
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--text-primary);
}
.btn-outline:hover {
    background-color: var(--primary-glow);
}
.btn-danger {
    background-color: rgba(244, 63, 94, 0.15);
    border: 1px solid var(--danger);
    color: #fda4af;
}
.btn-danger:hover {
    background-color: var(--danger);
    color: #fff;
    box-shadow: 0 4px 14px 0 var(--danger-glow);
}

/* LOADER / SPINNER */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(2, 4, 8, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: var(--transition);
}
.loader-content {
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 300px;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* LAYOUT DASHBOARD */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 90;
    flex-shrink: 0;
    background-color: rgba(10, 14, 23, 0.8);
}
.sidebar-brand {
    padding: 30px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}
.brand-icon {
    color: var(--primary);
}
.sidebar-nav {
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}
.nav-item {
    background: transparent;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}
.nav-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.04);
}
.nav-item.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-glow), var(--secondary-glow));
    border-left: 3px solid var(--primary);
}
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}
.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.btn-logout {
    width: 100%;
    padding: 10px;
    font-size: 0.85rem;
    background-color: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: #fda4af;
    border-radius: 8px;
    justify-content: center;
}
.btn-logout:hover {
    background-color: var(--danger);
    color: #fff;
}

/* CONTENT AREA */
.content-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 35px 35px;
}

/* TOPBAR */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    margin: 25px 0;
    border-radius: 16px;
}
.topbar-left h2 {
    font-size: 1.4rem;
    font-weight: 700;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pulse-indicator {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.6s infinite;
}
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.status-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* SECTIONS CONTAINER */
.sections-container {
    flex-grow: 1;
}
.content-section {
    display: none;
}
.content-section.active {
    display: block;
    animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* OVERVIEW ELEMENTS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}
.stat-card {
    padding: 24px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}
.stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.15);
}
.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-blue { background-color: rgba(99, 102, 241, 0.12); color: var(--primary); }
.icon-purple { background-color: rgba(139, 92, 246, 0.12); color: var(--secondary); }
.icon-green { background-color: rgba(16, 185, 129, 0.12); color: var(--success); }
.icon-orange { background-color: rgba(245, 158, 11, 0.12); color: var(--warning); }

.stat-data h3 {
    font-size: 1.5rem;
    font-weight: 700;
}
.stat-data p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.grid-2-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

/* PANELS */
.panel {
    border-radius: 20px;
    padding: 24px;
}
.panel-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 20px;
}
.panel-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
}
.health-indicators {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.indicator-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.indicator-row span:last-child {
    color: var(--text-primary);
    font-weight: 600;
}

/* BADGES */
.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}
.badge-success { background-color: rgba(16, 185, 129, 0.12); color: var(--success); }
.badge-danger { background-color: rgba(244, 63, 94, 0.12); color: #fda4af; }
.badge-warning { background-color: rgba(245, 158, 11, 0.12); color: var(--warning); }

/* ACTIVITY TIMELINE */
.activity-timeline {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.activity-item {
    position: relative;
    padding-left: 20px;
    font-size: 0.85rem;
}
.activity-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary);
}
.activity-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.activity-desc {
    color: var(--text-primary);
}

/* ACTIONS BAR */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 320px;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
}
.search-wrapper input {
    width: 100%;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 16px 10px 38px;
    color: var(--text-primary);
    outline: none;
    font-size: 0.9rem;
    transition: var(--transition);
}
.search-wrapper input:focus {
    border-color: var(--primary);
    background-color: rgba(20, 30, 54, 0.75);
}

/* TABLES SYSTEM */
.table-container {
    border-radius: 20px;
    overflow: hidden;
}
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
th, td {
    padding: 16px 20px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
}
th {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-weight: 600;
}
tr:last-child td {
    border-bottom: none;
}
tbody tr {
    transition: var(--transition);
}
tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.015);
}

/* TABLE SPECIAL RENDERERS */
.td-logo {
    width: 80px;
}
.table-logo-img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}
.table-logo-fallback {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
}
.table-actions {
    display: flex;
    gap: 8px;
}
.table-colors {
    display: flex;
    gap: 6px;
    align-items: center;
}
.table-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
}
.table-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.table-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition);
    word-break: break-all;
}
.table-link:hover {
    color: var(--secondary);
    text-decoration: underline;
}
.table-link-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* FORM LAYOUTS */
.form-layout-2-columns {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 25px;
}
.logo-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.logo-upload-area label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
}
.logo-preview-box {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: rgba(0,0,0,0.15);
}
.logo-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.logo-preview-box span {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.form-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.form-colors-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 12px;
}
.color-picker-wrap input[type="color"] {
    border: none;
    background: transparent;
    width: 32px;
    height: 32px;
    cursor: pointer;
}
.hex-span {
    font-size: 0.85rem;
    font-weight: 600;
    font-family: monospace;
}

/* MODALS STRUCTURE */
.modal-content {
    width: 100%;
    max-width: 580px;
    border-radius: 24px;
    padding: 30px;
    position: relative;
    box-shadow: 0 15px 45px rgba(0,0,0,0.6);
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 25px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

/* RESPONSIVE LAYOUT (Max width 992px) */
@media (max-width: 992px) {
    .dashboard-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .sidebar-brand {
        padding: 16px 20px;
    }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 12px 20px;
    }
    .nav-item {
        padding: 8px 14px;
        white-space: nowrap;
    }
    .user-badge {
        display: none;
    }
    .sidebar-footer {
        padding: 10px 20px;
        display: flex;
        justify-content: flex-end;
        border-top: none;
    }
    .btn-logout {
        width: auto;
    }
    .content-area {
        padding: 0 20px 20px;
    }
    .grid-2-columns {
        grid-template-columns: 1fr;
    }
}

/* RESPONSIVE TABLES (MOBILE CARD CONVERTER) */
@media (max-width: 768px) {
    .table-mobile-card thead {
        display: none;
    }
    .table-mobile-card tr {
        display: block;
        background-color: var(--bg-panel);
        border: 1px solid var(--border-color);
        border-radius: 16px;
        margin-bottom: 16px;
        padding: 16px;
    }
    .table-mobile-card td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        text-align: right;
        font-size: 0.85rem;
    }
    .table-mobile-card td:last-child {
        border-bottom: none;
        padding-top: 12px;
        justify-content: flex-end;
    }
    /* Insere legendas identificando os campos */
    .table-mobile-card td::before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.8rem;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    .td-logo {
        width: 100% !important;
    }
}
