/* public/css/layout.css */

#main-app-container {
  display: grid;
  grid-template-rows: 45px 1fr 7px 150px; 
  grid-template-columns: 7px 30% auto 1fr 7px; 
  width: 100%;
  height: 100%;
  position: relative;
}

/* --- Top Header Bar --- */
#app-header {
    grid-row: 1 / 2;
    grid-column: 1 / 6;
    background-color: var(--color-frame);
    z-index: 200;
    display: grid;
    grid-template-columns: 7px 30% auto 1fr 7px;
    align-items: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.5rem;
    /* Outer shadow cast downward onto main content */
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

#header-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

#header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-controls-container {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

@keyframes live-pulse-bg {
    0% { background-color: #c026d3; } /* Fuchsia-700 */
    50% { background-color: #f472b6; } /* Rose-400 */
    100% { background-color: #c026d3; }
}

@keyframes live-text-flash {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

#live-connect-container {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    display: none; 
    visibility: hidden; /* Hide the physical button since the banner is now the button */
    pointer-events: none;
    justify-content: center;
    align-items: center;
    z-index: 201; 
}

#live-connect-container.is-live-available {
    display: flex;
}

#connect-to-live-btn {
    padding: 0.25rem 1.25rem;
    font-size: 1rem;
    font-weight: 700;
    background-color: var(--color-accent-highlight-1, #fbbf24);
    color: #000;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

#connect-to-live-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

#connect-to-live-btn.waiting-mode {
    background-color: #4b5563;
    color: #fff;
    cursor: default;
}

#live-connect-container.is-live-available #connect-to-live-btn {
    animation: live-pulse-bg 2.5s infinite ease-in-out;
}

#live-connect-container.is-live-available #connect-to-live-btn span {
    animation: live-text-flash 1.5s infinite;
}

#connect-to-live-btn.disconnect-mode {
    background-color: #4b5563; 
    border-color: #374151;
    animation: none;
}

#connect-to-live-btn.disconnect-mode span {
    animation: none;
}


#left-frame {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    background-color: var(--color-frame);
    /* Outer shadow cast right onto command console */
    box-shadow: 4px 0 8px rgba(0,0,0,0.3);
}

#right-frame {
    grid-column: 5 / 6;
    grid-row: 2 / 5;
    background-color: var(--color-frame);
    /* Outer shadow cast left onto main screen and player */
    box-shadow: -4px 0 8px rgba(0,0,0,0.3);
}

#bottom-frame {
    grid-column: 1 / 5;
    grid-row: 3 / 4;
    background-color: var(--color-frame);
    /* Outer shadow cast up onto player */
    box-shadow: 0 -4px 8px rgba(0,0,0,0.3);
}


/* --- Left Command Console --- */
#command-console {
  grid-row: 2 / 3;
  grid-column: 2 / 3;
  background-color: var(--color-console-main);
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-radius: 15px; /* ALL around */
  overflow: hidden; 
}

/* --- Bottom-Left Playlist Panel --- */
#playlist-view-panel {
    grid-row: 4 / 5;
    grid-column: 2 / 3; /* Match AI window width */
    background-color: var(--color-playbar-accent-bg);
    box-shadow: inset 0 5px 10px rgba(0,0,0,0.5);
    z-index: 101;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 15px; /* ALL around */
}

/* --- Vertical Navigation Bar --- */
#main-nav-bar {
    grid-row: 2 / 3;
    grid-column: 3 / 4;
    display: flex;
    align-items: center;
    background-color: var(--color-frame);
    justify-content: center;
    z-index: 102;
    position: relative;
    /* Outer shadows cast onto adjacent content */
    box-shadow: 
        3px 0 6px rgba(0,0,0,0.2),
        -3px 0 6px rgba(0,0,0,0.2);
}

/* Integrated nav container - vertical icon spacing */
#integrated-nav {
    display: flex;
    flex-direction: column;
    gap: 2.25vh; /* Triple the default spacing (0.75vh base * 3) */
}

#nav-filler {
    grid-row: 4 / 5;
    grid-column: 3 / 4;
    background-color: var(--color-frame);
}

/* --- Main Screen --- */
#main-screen {
  grid-row: 2 / 3;
  grid-column: 4 / 5;
  min-width: 0;
  min-height: 0;
  position: relative; 
  display: flex;
  flex-direction: column;
  background-color: var(--color-windows-bg);
  box-sizing: border-box;
  overflow: hidden;
  border-radius: 15px; /* ALL around */
}

/* --- New Channel Title Banner inside Main Screen --- */
#channel-title-banner {
    width: 100%;
    /* Match the visual height of the Live box header in sonic-lounge */
    height: 38px; 
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-tertiary); /* Tertiary color */
    border: none; /* Removed border that was affecting vertical centering */
    box-shadow: 0 1px 0 var(--color-border-secondary); /* Use shadow for bottom line instead of border */
    background-image: none;
    box-sizing: border-box;
    flex-shrink: 0;
}

#channel-title-banner h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Bungee Inline', cursive;
    color: var(--color-text-title); /* Match standard title text color */
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Bottom-Right Player Panel --- */
#persistent-player-container {
    grid-row: 4 / 5; 
    grid-column: 4 / 5; 
    background-color: var(--color-frame);
    z-index: 101;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* --- Fix: Ensure it behaves like the other frame components --- */
    gap: 5px; /* Added 5px space between player elements */
    padding: 0;
    border: none !important;
    border-radius: 15px !important; /* ALL around */
    box-shadow: none !important;
    box-sizing: border-box;
}

/* --- Wrapper for Channels (inside #main-screen) --- */
#channel-wrapper {
  flex-grow: 1;
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column; 
}

/* ==================== MOBILE RESPONSIVE STYLES ==================== */
@media (max-width: 768px) {
    /* Main app container - stack everything vertically */
    #main-app-container {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 100vh;
        grid-template-rows: auto !important;
        grid-template-columns: unset !important;
    }
    
    /* Header - keep horizontal but compact */
    #app-header {
        position: sticky !important;
        top: 0;
        z-index: 200;
        flex-wrap: wrap;
        padding: 0.25rem !important;
        min-height: 45px;
    }
    
    /* Hide decorative frames on mobile */
    #left-frame,
    #right-frame,
    #bottom-frame,
    #live-connect-container {
        display: none !important;
    }
    
    /* Command Console - full width, below header */
    #command-console {
        grid-row: unset !important;
        grid-column: unset !important;
        width: 100% !important;
        height: 40vh !important;
        min-height: 250px;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    
    /* Playlist panel - below console */
    #playlist-view-panel {
        grid-row: unset !important;
        grid-column: unset !important;
        width: 100% !important;
        height: 25vh !important;
        min-height: 150px;
        border-radius: 0 !important;
    }
    
    /* Navigation bar - horizontal strip */
    #main-nav-bar {
        grid-row: unset !important;
        grid-column: unset !important;
        order: -1; /* Move to top */
        height: 40px !important;
        min-height: 40px;
        flex-direction: row !important;
        padding: 0.25rem !important;
    }
    
    #nav-filler {
        display: none !important;
    }
    
    /* Main screen - takes remaining space */
    #main-screen {
        grid-row: unset !important;
        grid-column: unset !important;
        width: 100% !important;
        min-height: 300px;
        flex: 1;
        border-radius: 0 !important;
    }
    
    /* Player container - bottom of screen */
    #persistent-player-container {
        grid-row: unset !important;
        grid-column: unset !important;
        position: sticky !important;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        height: 80px !important;
        min-height: 80px;
        border-radius: 0 !important;
        z-index: 150;
        flex-direction: column !important;
        padding: 0.25rem !important;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    #app-header {
        padding: 0.15rem !important;
    }
    
    #command-console {
        height: 35vh !important;
    }
    
    #playlist-view-panel {
        height: 20vh !important;
        min-height: 120px;
    }
    
    #persistent-player-container {
        height: 70px !important;
        min-height: 70px;
    }
}
