/* ==========================================================================
   DESIGN SYSTEM & CSS VARIABLES
   ========================================================================== */
:root {
    /* Color Palette */
    --bg-dark: #07090e;
    --bg-main: #0B0F19;
    --bg-card: rgba(17, 24, 39, 0.55);
    --bg-card-hover: rgba(31, 41, 55, 0.8);
    
    --border-color: rgba(255, 255, 255, 0.07);
    --border-color-focus: rgba(255, 255, 255, 0.25);
    
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    
    /* Neon Accents */
    --teal: #14b8a6;
    --blue: #3b82f6;
    --purple: #a855f7;
    --yellow: #eab308;
    --orange: #f97316;
    --pink: #ec4899;
    --cyan: #06b6d4;
    --indigo: #6366f1;
    --green: #22c55e;
    --red: #ef4444;
    --rose: #f43f5e;
    
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   GLOBAL RESET & STYLES
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.05) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(20, 184, 166, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
}

h1, h2, h3, h4, .brand-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* Scrollbar customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Utility Helpers */
.hide {
    display: none !important;
}

/* ==========================================================================
   GLASSMORPHISM UTILITY
   ========================================================================== */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-premium);
}

/* ==========================================================================
   AUTH SCREEN (Microsoft login)
   ========================================================================== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--bg-dark);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.nml-logo {
    display: inline-flex;
    gap: 8px;
    margin-bottom: 20px;
}

.nml-logo .dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
}

.nml-logo .dot.primary { background-color: var(--teal); box-shadow: 0 0 10px var(--teal); }
.nml-logo .dot.secondary { background-color: var(--blue); box-shadow: 0 0 10px var(--blue); }
.nml-logo .dot.tertiary { background-color: var(--pink); box-shadow: 0 0 10px var(--pink); }

.nml-logo.mini .dot {
    width: 8px;
    height: 8px;
}

.logo-area h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 500;
}

.auth-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color) 20%, var(--border-color) 80%, transparent);
    margin: 30px 0;
}

.auth-action-area h3 {
    font-size: 18px;
    margin-bottom: 10px;
}

.auth-action-area .desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.btn-microsoft {
    width: 100%;
    background-color: #2F2F2F;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 20px;
    font-weight: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-microsoft:hover {
    background-color: #3F3F3F;
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-microsoft:active {
    transform: translateY(0);
}

.provider-logo {
    width: 20px;
    height: 20px;
}

.error-msg {
    margin-top: 15px;
    color: var(--red);
    font-size: 12px;
    background: rgba(239, 68, 68, 0.1);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.auth-footer {
    margin-top: 40px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

/* ==========================================================================
   APP SHELL LAYOUT (Header)
   ========================================================================== */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
}

.header-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
}

.active-module-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--green);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 1px solid var(--border-color);
    padding-left: 20px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--purple);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    color: white;
    font-size: 14px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
}

.user-email {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-icon-logout {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition-fast);
}

.btn-icon-logout:hover {
    color: var(--red);
    background: rgba(239, 68, 68, 0.08);
}

.app-main-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

/* ==========================================================================
   ODOO-STYLE APPS GRID
   ========================================================================== */
.dashboard-grid-container {
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease-out;
}

.dashboard-banner {
    margin-bottom: 35px;
}

.dashboard-banner h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 6px;
}

.dashboard-banner p {
    color: var(--text-secondary);
    font-size: 15px;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.app-card {
    border-radius: 12px;
    padding: 24px;
    display: flex;
    gap: 16px;
    align-items: center;
    position: relative;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: var(--transition-smooth);
    overflow: hidden;
}

.app-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 100% 100%, rgba(255, 255, 255, 0.02), transparent 70%);
    pointer-events: none;
}

.app-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: var(--accent-color);
    box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.05);
    transition: var(--transition-smooth);
}

.app-meta {
    flex: 1;
}

.app-meta h3 {
    font-size: 15px;
    margin-bottom: 4px;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.app-meta p {
    font-size: 12px;
    color: var(--text-muted);
}

.badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.badge.active {
    background: rgba(236, 72, 153, 0.1);
    border-color: rgba(236, 72, 153, 0.2);
    color: var(--pink);
}

/* Active app interactions */
.app-card.active-card {
    cursor: pointer;
}

.app-card.active-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(236, 72, 153, 0.25);
    box-shadow: 0 12px 25px -5px rgba(236, 72, 153, 0.1);
    transform: translateY(-3px);
}

.app-card.active-card:hover .app-icon {
    background: rgba(236, 72, 153, 0.1);
    border-color: rgba(236, 72, 153, 0.3);
    transform: scale(1.05);
}

.app-card.active-card:active {
    transform: translateY(-1px);
}

/* Disabled card styling */
.app-card.disabled {
    opacity: 0.65;
    background: rgba(17, 24, 39, 0.25);
}

/* Micro-animations */
.pulse-accent {
    animation: softPulse 3s infinite;
}

@keyframes softPulse {
    0%, 100% { box-shadow: 0 0 0 rgba(236, 72, 153, 0); }
    50% { box-shadow: 0 0 12px rgba(236, 72, 153, 0.35); }
}

/* ==========================================================================
   MODULE WORKSPACE (Spreadsheets layout)
   ========================================================================== */
.module-workspace {
    animation: fadeIn 0.2s ease-out;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.module-subheader {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 18px;
    flex-wrap: wrap;
}

.btn-back {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-color-focus);
}

.module-subheader h2 {
    font-size: 20px;
    font-weight: 600;
}

.sheet-tabs {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-left: auto;
}

.tab-item {
    background: none;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.tab-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.tab-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Toolbar Control Bar */
.toolbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-input-wrapper {
    position: relative;
    width: 240px;
}

.search-input-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input-wrapper input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 8px 12px 8px 36px;
    border-radius: 8px;
    outline: none;
    transition: var(--transition-fast);
}

.search-input-wrapper input:focus {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--border-color-focus);
}

.btn-toolbar-action {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.btn-toolbar-action:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border-color: var(--border-color-focus);
}

.btn-primary {
    background: var(--pink);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.25);
    transition: var(--transition-fast);
}

.btn-primary:hover {
    background: #e1277a;
    box-shadow: 0 4px 16px rgba(236, 72, 153, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.selected-rows-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-right: 10px;
}

/* ==========================================================================
   NOTION-STYLE SPREADSHEET GRID
   ========================================================================== */
.notion-grid-wrapper {
    flex: 1;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: #0f1322;
    display: flex;
    flex-direction: column;
}

.notion-grid-inner {
    overflow: auto;
    flex: 1;
}

.notion-style-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
}

/* Notion Headers */
.notion-style-table th {
    background: #141a2e;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    padding: 10px 14px;
    border-right: 1px solid var(--border-color);
    border-bottom: 2px solid var(--border-color);
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

.notion-style-table th:last-child {
    border-right: none;
}

.th-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.th-content i {
    font-size: 10px;
    color: var(--text-muted);
}

.th-content .sort-icon {
    margin-left: auto;
    color: var(--pink);
    opacity: 0.8;
}

/* Table cells and rows */
.notion-style-table td {
    padding: 8px 14px;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    height: 38px;
    vertical-align: middle;
    position: relative;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notion-style-table td:last-child {
    border-right: none;
}

.notion-style-table tr {
    background: transparent;
    transition: background-color 0.1s ease;
}

.notion-style-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Action column */
.action-cell {
    display: flex;
    justify-content: center;
    gap: 8px;
    width: 60px;
    padding: 4px !important;
}

.btn-cell-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    font-size: 12px;
    transition: var(--transition-fast);
}

.btn-cell-delete:hover {
    color: var(--red);
    background: rgba(239, 68, 68, 0.08);
}

/* Notion row checkboxes */
.checkbox-cell {
    width: 40px;
    text-align: center;
    padding: 4px !important;
}

.row-selector {
    cursor: pointer;
    accent-color: var(--pink);
}

/* Inline Grid Editor elements */
.grid-cell-value {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    cursor: cell;
}

.grid-cell-value.empty-cell {
    color: var(--text-muted);
    font-style: italic;
}

.cell-editor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid var(--pink);
    background: #141a2e;
    color: var(--text-primary);
    padding: 0 12px;
    outline: none;
    font-family: inherit;
    font-size: inherit;
    z-index: 5;
}

.cell-select-editor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid var(--pink);
    background: #141a2e;
    color: var(--text-primary);
    padding: 0 8px;
    outline: none;
    z-index: 5;
}

/* Cell Types specific display styles */
.badge-cell-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.badge-status-running { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.badge-status-completed { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.badge-status-failed { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.badge-status-pending { background: rgba(234, 179, 8, 0.15); color: var(--yellow); }

/* Empty state message inside grid */
.grid-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 12px;
    text-align: center;
}

.grid-empty i {
    font-size: 36px;
    color: var(--border-color-focus);
}

/* ==========================================================================
   LOCKED MODULE EMPTY STATE LAYOUT
   ========================================================================== */
.empty-module-container {
    max-width: 600px;
    margin: 80px auto 0;
    padding: 50px;
    border-radius: 16px;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.empty-icon {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 24px;
    opacity: 0.6;
}

.empty-module-container h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.empty-module-container p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    line-height: 1.6;
}

/* ==========================================================================
   MEDIA QUERY RESPONSIVENESS
   ========================================================================== */
@media (max-width: 768px) {
    .app-header {
        padding: 0 16px;
    }
    .user-info {
        display: none;
    }
    .toolbar-container {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .search-input-wrapper {
        width: 100%;
    }
    .sheet-tabs {
        margin-left: 0;
        width: 100%;
        overflow-x: auto;
    }
}
