/* ============================================
   MOSESTRO SHELL - INDUSTRIAL AESTHETIC
   ============================================ */

/* CSS Variables - shared with apps */
:root {
    /* Primary palette - Deep slate blue with amber accents */
    --color-bg-dark: #0f1419;
    --color-bg-panel: #1a2129;
    --color-bg-section: #232d38;
    --color-bg-hover: #2a3643;
    --color-bg-active: #3a4755;

    --color-text-primary: #e8edf3;
    --color-text-secondary: #8b98a8;
    --color-text-muted: #5c6a7a;

    --color-accent: #f0b429;
    --color-accent-hover: #f7c94b;
    --color-accent-dim: rgba(240, 180, 41, 0.15);

    --color-border: #2d3a47;
    --color-border-light: #3d4a57;

    /* Status colors */
    --color-new: #4da6ff;
    --color-in-progress: #9ca3af;
    --color-allowed: #22c55e;
    --color-declined: #ef4444;

    /* Fonts */
    --font-display: 'Space Grotesk', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
    --spacing-xl: 1.5rem;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;

    /* Sidebar */
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-display);
    background-color: var(--color-bg-dark);
    color: var(--color-text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1419 0%, #1a2129 50%, #0f1419 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.login-container {
    background: var(--color-bg-panel);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.4),
        0 0 0 1px var(--color-border);
    width: 100%;
    max-width: 380px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--color-text-primary);
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
}

.login-container .brand-subtitle {
    display: block;
    text-align: center;
    margin-bottom: 2rem;
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--color-accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-family: var(--font-mono);
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login-form input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: var(--font-mono);
    background: var(--color-bg-section);
    color: var(--color-text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.login-form input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-dim);
}

.error-message {
    color: var(--color-declined);
    background: rgba(239, 68, 68, 0.1);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-top: 1rem;
    font-size: 0.875rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-display);
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-accent) 0%, #e09f1f 100%);
    color: var(--color-bg-dark);
    width: 100%;
    font-weight: 600;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-accent-hover) 0%, var(--color-accent) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(240, 180, 41, 0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================
   SHELL LAYOUT
   ============================================ */
.shell-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
#sidebar {
    width: var(--sidebar-collapsed-width);
    background: var(--color-bg-panel);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 2000;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transition: width 0.25s ease, box-shadow 0.25s ease;
}

#sidebar.expanded {
    width: var(--sidebar-width);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
}

#sidebar .sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--color-border);
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
}

.logo-mark {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-accent);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-accent-dim);
    border-radius: 6px;
    flex-shrink: 0;
}

#sidebar.expanded .logo-mark {
    display: none;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.02em;
    display: none;
}

#sidebar.expanded .logo-text {
    display: block;
}

.logo-subtitle {
    font-size: 0.625rem;
    font-weight: 400;
    color: var(--color-accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-family: var(--font-mono);
    margin-top: 0.125rem;
    display: none;
}

#sidebar.expanded .logo-subtitle {
    display: block;
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.75rem;
    border-radius: 8px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 0.25rem;
    text-decoration: none;
    border: 1px solid transparent;
}

#sidebar.expanded .menu-item {
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.menu-item:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

.menu-item.active {
    background: var(--color-accent-dim);
    color: var(--color-accent);
    border-color: rgba(240, 180, 41, 0.3);
}

.menu-group {
    margin-bottom: 0.25rem;
}

.menu-item-parent {
    position: relative;
}

.menu-expand-icon {
    margin-left: auto;
    width: 14px;
    height: 14px;
    display: none;
    color: var(--color-text-muted);
    transition: transform var(--transition-fast), color var(--transition-fast);
}

#sidebar.expanded .menu-expand-icon {
    display: inline-flex;
}

.menu-group.expanded .menu-expand-icon {
    transform: rotate(180deg);
    color: var(--color-text-secondary);
}

.menu-sub-items {
    display: none;
    padding-left: 2.25rem;
    margin-top: 0.25rem;
    gap: 0.25rem;
    flex-direction: column;
}

.menu-group.expanded .menu-sub-items {
    display: flex;
}

.menu-sub-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.menu-sub-item:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

.menu-sub-item-empty {
    cursor: default;
    color: var(--color-text-muted);
}

.menu-sub-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-border-light);
    flex-shrink: 0;
}

.menu-sub-dot.active {
    background: var(--color-accent);
}

.menu-sub-label {
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-sub-rename {
    border: none;
    background: transparent;
    padding: 0;
    color: var(--color-text-muted);
    cursor: pointer;
    display: inline-flex;
}

.menu-sub-upload {
    margin-left: auto;
    border: none;
    background: transparent;
    padding: 0;
    color: var(--color-text-muted);
    cursor: pointer;
    display: inline-flex;
}

.menu-sub-upload svg {
    width: 14px;
    height: 14px;
}

.menu-sub-upload:hover,
.menu-sub-rename:hover {
    color: var(--color-text-primary);
}

.menu-sub-rename svg {
    width: 14px;
    height: 14px;
}

.menu-sub-input {
    flex: 1;
    font-size: 0.8125rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-dark);
    color: var(--color-text-primary);
}

#sidebar:not(.expanded) .menu-sub-items {
    display: none;
}

.menu-icon {
    width: 20px;
    height: 20px;
    stroke-width: 1.5;
    flex-shrink: 0;
}

.menu-label {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
}

#sidebar.expanded .menu-label {
    display: block;
}

.menu-badge {
    margin-left: auto;
    padding: 0.125rem 0.5rem;
    background: var(--color-bg-section);
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    display: none;
}

#sidebar.expanded .menu-badge {
    display: block;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-display);
    transition: all var(--transition-fast);
}

.logout-btn span {
    display: none;
}

#sidebar.expanded .logout-btn {
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

#sidebar.expanded .logout-btn span {
    display: inline;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-declined);
}

/* ============================================
   APP CONTAINER
   ============================================ */
.app-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--color-bg-dark);
    margin-left: var(--sidebar-collapsed-width);
}

/* App Loading State */
.app-loading {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--color-text-secondary);
    gap: 1rem;
}

.app-loading.visible {
    display: flex;
}

.app-loading p {
    font-size: 0.875rem;
}

/* App Frame (for iframe-based apps) */
.app-frame {
    width: 100%;
    height: 100%;
    border: none;
}

/* App Content (for JS-based apps) */
.app-content {
    width: 100%;
    height: 100%;
    overflow: auto;
}

/* Placeholder App */
.placeholder-app {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--color-text-muted);
    gap: 1rem;
}

.placeholder-icon {
    width: 64px;
    height: 64px;
    opacity: 0.5;
}

.placeholder-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.placeholder-subtitle {
    font-size: 0.875rem;
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--color-bg-section);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-bg-panel);
    color: var(--color-text-primary);
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    z-index: 2000;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--color-border);
    font-size: 0.875rem;
    animation: toastSlideIn 0.3s ease;
}

.toast.success {
    border-color: var(--color-allowed);
    background: linear-gradient(135deg, var(--color-bg-panel) 0%, rgba(34, 197, 94, 0.1) 100%);
}

.toast.error {
    border-color: var(--color-declined);
    background: linear-gradient(135deg, var(--color-bg-panel) 0%, rgba(239, 68, 68, 0.1) 100%);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================
   SPS Upload Modal
   ============================================ */
.sps-upload-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2500;
    padding: 1rem;
}

.sps-upload-modal.visible {
    display: flex;
}

.sps-upload-dialog {
    width: min(460px, 100%);
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border-light);
    border-radius: 10px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.sps-upload-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.sps-upload-header h3 {
    font-size: 0.95rem;
    color: var(--color-text-primary);
}

.sps-upload-close {
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.sps-upload-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1rem;
}

.sps-upload-form label {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.sps-upload-form input[type="file"] {
    margin-top: 0.35rem;
    width: 100%;
    font-size: 0.8rem;
    color: var(--color-text-primary);
}

.sps-upload-note {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.sps-upload-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.sps-upload-btn {
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.sps-upload-btn.secondary {
    background: var(--color-bg-section);
    color: var(--color-text-secondary);
}

.sps-upload-btn.primary {
    background: var(--color-accent);
    color: var(--color-bg-dark);
    border-color: transparent;
    font-weight: 600;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: var(--color-bg-dark);
    border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-light);
}

/* ============================================
   APP ICONS (SVG definitions)
   ============================================ */
.icon-map {
    /* Map/Planning icon */
}

.icon-database {
    /* Data icon */
}

.icon-dollar {
    /* Price icon */
}

.icon-gauge {
    /* Well Monitoring icon */
}

.icon-tool {
    /* Equipment icon */
}

.icon-file {
    /* Licenses icon */
}
