/**
 * Bazis 3D Viewer - Minimalist Monochrome Design
 * Light, Airy Space with Technological Feel
 */

/* Import Google Fonts - Modern, clean typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

/* Page-specific styles */
@import url('../pages/projects/projects.css');
@import url('../pages/viewer/viewer.css');
@import url('../pages/supply/supply.css');
@import url('../pages/assembly/assembly.css');
@import url('../pages/kanban/kanban.css');
@import url('../pages/executive/executive.css');
@import url('../pages/profile/profile.css');
@import url('../pages/profile/orders/orders.css');
@import url('../pages/profile/portfolio/portfolio.css');
@import url('../pages/profile/companies/companies.css');

/* Components */
@import url('../components/project-modal.css');
@import url('../components/kanban/kanban-board.css');

/* CSS Variables */
:root {
    /* Color Palette - Pure Monochrome */
    --color-white: #ffffff;
    --color-cream: #fafafa;
    --color-sand-50: #f8f8f8;
    --color-sand-100: #f2f2f2;
    --color-sand-200: #e8e8e8;
    --color-sand-300: #d9d9d9;
    --color-sand-400: #bfbfbf;
    --color-stone-500: #8c8c8c;
    --color-stone-600: #666666;
    --color-charcoal: #404040;
    --color-dark: #262626;

    /* Accent Colors - Monochrome */
    --color-sage: #808080;
    --color-sage-hover: #666666;
    --color-clay: #999999;
    --color-blue-muted: #9db4c6;

    /* Semantic Variables */
    --bg-app: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    --bg-panel: rgba(255, 255, 255, 0.6);
    --bg-panel-hover: rgba(255, 255, 255, 0.75);
    --bg-canvas: #fafafa;
    --bg-button: rgba(248, 248, 248, 0.8);
    --bg-button-hover: rgba(255, 255, 255, 0.95);

    --text-main: var(--color-dark);
    --text-secondary: var(--color-stone-600);
    --text-muted: var(--color-stone-500);

    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-light: rgba(0, 0, 0, 0.08);

    /* Spacing System - Generous for airy feel */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 40px;
    --space-8: 48px;
    --space-10: 64px;

    /* Radius - Soft, organic */
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --radius-full: 9999px;

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

    /* Suede/Matte Effects */
    --texture-noise: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" stitchTiles="stitch"/></filter><rect width="200" height="200" filter="url(%23noise)" opacity="0.03"/></svg>');
    --shadow-soft: 0 8px 32px -8px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.02);
    --shadow-medium: 0 12px 48px -12px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 16px 56px -16px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-app);
    color: var(--text-main);
    overflow: auto;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Canvas Area - Light, Expansive Space */
#canvas-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    background: var(--bg-app);
}

/* ========================================
   COMMON PANEL STYLES - Frosted Glass Suede Effect
   ======================================== */
.panel {
    background: var(--bg-panel);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-soft);
    animation: panelFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

/* Subtle texture overlay for suede effect */
.panel::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    background: var(--texture-noise);
    pointer-events: none;
    opacity: 0.4;
}

.panel h3 {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.panel h4 {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: var(--space-6);
    margin-bottom: var(--space-4);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ========================================
   LEFT PANEL - CONTROLS
   ======================================== */
#info-panel {
    position: absolute;
    top: var(--space-7);
    left: var(--space-7);
    width: 300px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    z-index: 10;
}

/* Info Stats */
.info-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
    line-height: 1.4;
}

.info-label {
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
    min-width: 70px;
}

.info-value {
    color: var(--text-main);
    word-break: break-word;
}

#model-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
    background: var(--bg-button);
    backdrop-filter: blur(8px);
    padding: var(--space-5);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

#selection-info {
    background: var(--bg-button);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
}

#selection-info p {
    margin-bottom: 3px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 300;
}

#selection-info strong {
    color: var(--text-main);
    font-weight: 500;
}

/* Selection Info - Enhanced Styles */
.selection-empty {
    color: var(--text-muted);
    font-style: italic;
}

.selection-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: var(--space-4);
}

.selection-panel-info,
.selection-block-info,
.selection-furniture-info {
    font-size: 12px;
}

.selection-materials {
    margin: var(--space-3) 0;
    padding: var(--space-3) 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.selection-material-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    font-size: 11px;
}

.selection-material-item .material-name {
    color: var(--text-main);
    font-weight: 500;
}

.selection-material-item .material-details {
    color: var(--text-muted);
}

.selection-totals {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

/* ========================================
   MATERIALS LIST - Enhanced Styles
   ======================================== */
#materials-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.material-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--bg-button);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.material-item:hover {
    background: var(--bg-button-hover);
    border-color: var(--border-light);
}

.material-item.hidden {
    opacity: 0.4;
    text-decoration: line-through;
}

.material-main {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
    cursor: pointer;
}

.material-color {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.material-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.material-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-main);
    word-break: break-word;
    line-height: 1.3;
}

.material-stats {
    font-size: 10px;
    color: var(--text-muted);
}

.material-delete-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    padding: 4px;
    flex: none;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.material-item:hover .material-delete-btn {
    opacity: 0.5;
}

.material-delete-btn:hover {
    opacity: 1 !important;
    background: rgba(239, 68, 68, 0.1);
}

.material-delete-btn svg {
    width: 14px;
    height: 14px;
    stroke: var(--text-muted);
}

.material-delete-btn:hover svg {
    stroke: #ef4444;
}

/* Button Groups */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

/* Buttons - Soft, Matte, Minimalist */
button {
    appearance: none;
    background: var(--bg-button);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
    font-family: var(--font-sans);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    min-width: fit-content;
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.04);
    position: relative;
}

button::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-md);
    background: var(--texture-noise);
    pointer-events: none;
    opacity: 0.3;
}

button:hover {
    background: var(--bg-button-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.08);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px -1px rgba(0, 0, 0, 0.06);
}

.view-buttons button {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: var(--radius-full);
    font-size: 11px;
}

/* Icons in buttons */
button svg {
    width: 14px;
    height: 14px;
    stroke: var(--text-secondary);
    transition: stroke 0.3s;
}

button:hover svg {
    stroke: var(--text-main);
}

/* ========================================
   RIGHT PANEL - TREE
   ======================================== */
#structure-panel {
    position: absolute;
    top: var(--space-7);
    right: var(--space-7);
    width: 340px;
    max-height: calc(100vh - 80px);
    z-index: 10;
    display: none;
}

/* ========================================
   TOP TOOLBAR - Horizontal Icon Buttons
   ======================================== */
#top-toolbar {
    position: absolute;
    top: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: var(--space-2);
    background: var(--bg-panel);
    backdrop-filter: blur(32px) saturate(140%);
    -webkit-backdrop-filter: blur(32px) saturate(140%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-soft);
    z-index: 15;
    max-width: 95vw;
    overflow: visible;
}

#top-toolbar::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    background: var(--texture-noise);
    pointer-events: none;
    opacity: 0.4;
}

#top-toolbar button {
    position: relative;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
}

#top-toolbar button::before {
    display: none;
}

#top-toolbar button:hover {
    background: var(--bg-button);
    border-color: var(--border-light);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.12);
}

#top-toolbar button:active {
    transform: translateY(0) scale(1);
    box-shadow: 0 1px 4px -1px rgba(0, 0, 0, 0.08);
}

#top-toolbar button svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-secondary);
    transition: stroke 0.3s;
}

#top-toolbar button:hover svg {
    stroke: var(--text-main);
}

/* Toolbar separator */
.toolbar-separator {
    width: 1px;
    height: 28px;
    background: var(--border-light);
    margin: 0 var(--space-2);
}

/* Active state for toggle buttons */
#top-toolbar button.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

#top-toolbar button.active svg {
    stroke: #3b82f6;
}

/* Tooltip effect - native browser tooltip via title attribute */
#top-toolbar button[title] {
    cursor: pointer;
}

#structure-tree {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding-right: 8px;
}

/* Tree Node Structure */
.tree-node {
    margin-bottom: var(--space-2);
}

.tree-node-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.tree-node-header:hover {
    background: rgba(248, 248, 248, 0.6);
    color: var(--text-main);
    transform: translateX(2px);
}

.tree-node.selected>.tree-node-header,
.tree-node-header.selected {
    background: rgba(131, 186, 255, 0.15);
    color: #83BAFF;
    font-weight: 500;
}

/* Tree Toggle (expand/collapse) */
.tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 10px;
    user-select: none;
}

.tree-toggle:hover {
    color: var(--text-main);
    transform: scale(1.1);
}

.tree-toggle svg {
    transition: inherit;
}

/* Custom Checkbox Styling */
.tree-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--bg-button);
    backdrop-filter: blur(4px);
}

.tree-checkbox:hover {
    border-color: var(--color-sage);
    background: var(--bg-button-hover);
}

.tree-checkbox:checked {
    background: var(--color-sage);
    border-color: var(--color-sage);
}

.tree-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Tree Node Name */
.tree-node-name {
    flex: 1;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    font-weight: 400;
    color: inherit;
    transition: color 0.2s;
}

.tree-node-name:hover {
    color: var(--text-main);
}

/* Panel and Furniture Nodes (children) */
.tree-panel,
.tree-furniture {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    padding-left: var(--space-5);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    margin-bottom: 2px;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
}

.tree-panel:hover,
.tree-furniture:hover {
    background: rgba(248, 248, 248, 0.6);
    color: var(--text-main);
    transform: translateX(2px);
}

.tree-panel.selected,
.tree-furniture.selected {
    background: rgba(131, 186, 255, 0.15);
    color: #83BAFF;
    font-weight: 500;
}

/* Enhanced Panel Content in Tree */
.tree-panel-content {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.tree-panel-name {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 2px;
    word-break: break-word;
}

.tree-panel-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
}

.tree-panel-details span {
    white-space: nowrap;
}

.tree-panel-material {
    color: var(--text-secondary);
    font-weight: 400;
}

/* Grouped Furniture in Tree */
.tree-furniture-group {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    padding-left: var(--space-5);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    margin-bottom: 2px;
}

.tree-furniture-group:hover {
    background: rgba(248, 248, 248, 0.6);
}

.tree-furniture-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    min-width: 0;
}

.tree-furniture-name {
    font-size: 11px;
    color: var(--text-secondary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-furniture-count {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.04);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

/* Tree Children Container */
.tree-children {
    margin-left: var(--space-5);
    margin-top: var(--space-1);
    padding-left: var(--space-3);
    border-left: 1px solid rgba(0, 0, 0, 0.05);
}

.tree-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    margin-bottom: 3px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.tree-item:hover {
    background: rgba(248, 248, 248, 0.6);
    color: var(--text-main);
    transform: translateX(2px);
}

.tree-item.selected {
    background: rgba(131, 186, 255, 0.15);
    color: #83BAFF;
    font-weight: 500;
}

.tree-item svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    opacity: 0.6;
}

/* ========================================
   MATERIALS IN LEFT PANEL
   ======================================== */
.material-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    margin-bottom: 4px;
}

.material-item:hover {
    background: rgba(248, 248, 248, 0.6);
    transform: translateX(2px);
}

.material-color {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* ========================================
   DROP ZONE
   ======================================== */
#drop-zone {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-panel);
    backdrop-filter: blur(32px) saturate(140%);
    -webkit-backdrop-filter: blur(32px) saturate(140%);
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-xl);
    padding: 80px 100px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-medium);
}

#drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-xl);
    background: var(--texture-noise);
    pointer-events: none;
    opacity: 0.5;
}

#drop-zone:hover,
#drop-zone.drag-over {
    border-color: var(--color-sage);
    transform: translate(-50%, -50%) scale(1.02);
    box-shadow: var(--shadow-hover);
}

.drop-icon {
    color: var(--color-sage);
    margin-bottom: var(--space-5);
}

.drop-icon svg {
    width: 72px;
    height: 72px;
    stroke: currentColor;
    stroke-width: 0.8;
    fill: rgba(128, 128, 128, 0.08);
}

#drop-zone h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: var(--space-3);
}

#drop-zone p {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 300;
    line-height: 1.8;
}

/* ========================================
   BOTTOM HELP BAR
   ======================================== */
#help-text {
    position: absolute;
    bottom: var(--space-7);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    padding: 12px 28px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-subtle);
    display: none;
    z-index: 5;
    white-space: nowrap;
}

#help-text::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    background: var(--texture-noise);
    pointer-events: none;
    opacity: 0.3;
}

/* ========================================
   SCROLL BARS - Minimal, Soft
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.2);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.35);
    background-clip: padding-box;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes panelFadeIn {
    from {
        opacity: 0;
        transform: translateY(16px);
        filter: blur(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   UTILITIES
   ======================================== */
.icon {
    width: 18px;
    height: 18px;
    stroke-width: 1.5;
    stroke: currentColor;
    fill: none;
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

/* Touch-friendly tap targets */
@media (pointer: coarse) {

    button,
    .btn-primary,
    .btn-secondary,
    .filter-tab,
    .icon-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .project-card,
    .exec-project-card,
    .activity-item {
        padding: var(--space-5);
    }
}

/* Mobile-first responsive utilities */
@media (max-width: 768px) {

    /* Header adjustments */
    .projects-header,
    .executive-header {
        flex-wrap: wrap;
        padding: var(--space-4);
        gap: var(--space-3);
    }

    .logo-text {
        display: none;
    }

    .header-search {
        order: 10;
        flex: 1 1 100%;
        max-width: 100%;
    }

    .role-switcher {
        order: 2;
    }

    /* Page title mobile */
    .page-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .title-actions {
        width: 100%;
    }

    .title-actions .btn-primary,
    .title-actions .btn-secondary {
        flex: 1;
    }

    .page-title {
        font-size: 18px;
    }

    /* KPI cards mobile */
    .kpi-row {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-3);
    }

    .kpi-card {
        padding: var(--space-4);
    }

    .kpi-value {
        font-size: 18px;
    }

    /* Stats row mobile */
    .stats-row {
        flex-direction: column;
        gap: var(--space-3);
    }

    /* Filter tabs scroll */
    .filter-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .filter-tabs::-webkit-scrollbar {
        display: none;
    }

    .filter-tab {
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* Projects grid mobile */
    .projects-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    /* Kanban mobile - full width columns */
    .kanban-board-wrapper {
        margin: 0 calc(-1 * var(--space-4));
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }

    .exec-kanban-column {
        flex: 0 0 85vw;
        max-height: 400px;
    }

    /* Activity sidebar - hidden on mobile (shown as modal) */
    .activity-sidebar {
        display: none;
    }

    /* Layout adjustments */
    .projects-layout,
    .executive-layout {
        padding: var(--space-4);
        flex-direction: column;
    }

    /* Pagination mobile */
    .pagination {
        flex-direction: column;
        gap: var(--space-3);
        text-align: center;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }

    .projects-filters {
        flex-direction: column;
        gap: var(--space-3);
    }

    .filter-actions {
        width: 100%;
        justify-content: space-between;
    }

    .exec-kanban-column {
        flex: 0 0 90vw;
    }
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {

    .projects-page,
    .executive-page {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .projects-header,
    .executive-header {
        padding-top: max(var(--space-5), env(safe-area-inset-top));
        padding-left: max(var(--space-7), env(safe-area-inset-left));
        padding-right: max(var(--space-7), env(safe-area-inset-right));
    }
}

/* PWA Standalone mode */
@media (display-mode: standalone) {

    .projects-header,
    .executive-header {
        padding-top: var(--space-6);
    }
}

/* Dynamic viewport height for mobile */
.projects-page,
.executive-page {
    min-height: 100vh;
    min-height: 100dvh;
}

/* Smooth scrolling for touch */
* {
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}