/* --- 1. THEME ENGINE (VARIABLES) --- */

/* Default Theme (Quartz Light) */
:root {
    --fiori-bg: #f5f7fa;
    --fiori-header: #354a5f;
    --fiori-tile-bg: #ffffff;
    --fiori-text: #32363a;
    --fiori-blue: #0854a0;
    --fiori-hover: #eaecee;
    --fiori-border: rgba(0,0,0,0.1);
}

/* Quartz Dark Theme */
[data-theme="dark"] {
    --fiori-bg: #1c2228;
    --fiori-header: #232a31;
    --fiori-tile-bg: #29313a;
    --fiori-text: #ffffff;
    --fiori-blue: #91c8f6;
    --fiori-hover: #3a4552;
    --fiori-border: rgba(255,255,255,0.1);
}

/* Horizon Theme (Modern SAP) */
[data-theme="horizon"] {
    --fiori-bg: #f5f6f7;
    --fiori-header: #ffffff;
    --fiori-tile-bg: #ffffff;
    --fiori-text: #1d2d3e;
    --fiori-blue: #0070f2;
    --fiori-hover: #eef4fc;
    --fiori-border: #d9d9d9;
}
/* Horizon Specific Overrides */
[data-theme="horizon"] .fiori-shell { 
    color: #333 !important; 
    border-bottom: 1px solid #ddd; 
}
[data-theme="horizon"] .fiori-shell .btn { color: #555; }
[data-theme="horizon"] .fiori-shell .btn:hover { background: #eee; }

/* High Contrast Theme */
[data-theme="hcw"] {
    --fiori-bg: #000000;
    --fiori-header: #000000;
    --fiori-tile-bg: #000000;
    --fiori-text: #ffffff;
    --fiori-blue: #ffffff;
    --fiori-hover: #333333;
    --fiori-border: #ffffff;
}

/* --- 2. GLOBAL LAYOUT --- */
body { 
    background-color: var(--fiori-bg); 
    color: var(--fiori-text);
    font-family: "72", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* NEW PADDING: 48px (Header) + 44px (Anchor Bar) = 92px */
    padding-top: 92px; 
    
    padding-bottom: 80px; 
    transition: background-color 0.3s, color 0.3s;
}

a { text-decoration: none; color: inherit; }

/* --- 3. SHELL HEADER --- */
.fiori-shell {
    background-color: var(--fiori-header);
    color: white;
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    /* Fixed Positioning */
    position: fixed; 
    top: 0; left: 0; right: 0; 
    width: 100%; 
    z-index: 1030;
    transition: background-color 0.3s;
}

/* --- 4. TILE GRID --- */
.group-section { margin-bottom: 2rem; }

.group-title {
    font-size: 1.1rem;
    color: var(--fiori-text);
    margin: 2rem 0 1rem 0;
    border-bottom: 1px solid var(--fiori-border);
    padding-bottom: 0.5rem;
    font-weight: bold;
    cursor: grab; /* Shows it is draggable */
}
.group-title:active { cursor: grabbing; }

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1rem;
    min-height: 100px; /* Drop zone area */
}

/* --- 5. TILE CARD --- */
.fiori-tile {
    background-color: var(--fiori-tile-bg);
    border: 1px solid var(--fiori-border);
    border-radius: 4px;
    height: 170px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    text-decoration: none;
    color: var(--fiori-text);
}

.fiori-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    background-color: var(--fiori-hover);
    border-color: var(--fiori-blue);
    color: var(--fiori-text);
}

/* Typography */
.tile-title { font-weight: 600; font-size: 0.95rem; line-height: 1.2; margin-bottom: 4px; }
.tile-subtitle { font-size: 0.75rem; opacity: 0.8; }
.tile-icon { font-size: 2.2rem; color: var(--fiori-blue); margin-top: auto; }

/* --- 6. BUTTONS --- */
.add-tile-btn {
    border: 2px dashed var(--fiori-border);
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    color: #999;
    cursor: pointer;
}
.add-tile-btn:hover {
    border-color: var(--fiori-blue);
    color: var(--fiori-blue);
    background-color: rgba(8, 84, 160, 0.05);
}

.tile-remove {
    position: absolute; top: 8px; right: 8px;
    color: #dc3545; background: var(--fiori-tile-bg);
    border: 1px solid var(--fiori-border);
    border-radius: 50%;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s;
    z-index: 10;
}
.fiori-tile:hover .tile-remove { opacity: 1; }

/* --- 7. ANIMATIONS & EXTRAS --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeIn 0.4s ease-out forwards; }

/* Sortable Ghost (The shadow when dragging) */
.sortable-ghost { opacity: 0.4; background: #eee; }

/* --- NEW: ANCHOR BAR NAVIGATION --- */
.anchor-bar {
    position: fixed;
    top: 48px; /* Starts exactly where the Header ends */
    left: 0;
    right: 0;
    height: 44px;
    background-color: var(--fiori-bg); /* Matches page background */
    border-bottom: 1px solid var(--fiori-border);
    z-index: 1020; /* Below Header (1030), Above Tiles */
    display: flex;
    overflow-x: auto; /* Horizontal Scroll on mobile */
    white-space: nowrap;
    padding: 0 1rem;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 4px 10px -4px rgba(0,0,0,0.05);
    /* Glassmorphism Effect */
    backdrop-filter: blur(10px);
    opacity: 0.98;
}

/* Hide Scrollbar */
.anchor-bar::-webkit-scrollbar { display: none; }
.anchor-bar { -ms-overflow-style: none; scrollbar-width: none; }

/* The Tabs */
.anchor-tab {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--fiori-text);
    cursor: pointer;
    padding: 10px 0;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    opacity: 0.7;
}

.anchor-tab:hover {
    color: var(--fiori-blue);
    opacity: 1;
}

/* Active State (Optional JS could toggle this) */
.anchor-tab.active {
    color: var(--fiori-blue);
    border-bottom-color: var(--fiori-blue);
    opacity: 1;
}