/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Variables */
:root {
    --remote-width: min(360px, 90vw);
    --remote-height: min(100vh - 40px, 800px);
    --button-size: min(70px, calc(var(--remote-width) * 0.2));
    --dpad-size: min(280px, calc(var(--remote-width) * 0.8));
    --ok-button-size: min(100px, calc(var(--dpad-size) * 0.36));
    --dir-button-size: min(60px, calc(var(--dpad-size) * 0.21));
    --vol-ch-width: min(80px, calc(var(--remote-width) * 0.22));
    --vol-ch-height: min(220px, calc(var(--remote-height) * 0.3));
    
    /* Colors */
    --bg-dark: #1a1a1a;
    --bg-button: #1E1E1E;
    --bg-button-secondary: #2F2F2F;
    --bg-button-active: #3a3939;
    --bg-button-active-light: #4c4c4c;
    --text-light: #D9D9D9;
}

/* Layout */
body {
    background-color: var(--bg-dark);
    min-height: 100vh;
    height: 100vh;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: Arial, sans-serif;
    overflow: hidden;
    position: fixed;
}

.remote-container {
    width: var(--remote-width);
    height: var(--remote-height);
    padding: min(15px, 4vw);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: min(12px, 2.5vh);
}

/* Logo */
#logo {
    width: min(180px, 50%);
    height: auto;
    max-height: 8vh;
    margin: -10px auto 0;
    display: block;
}

/* Power and Exit Section */
.power_exit {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: min(12px, 2.5vh);
    padding: 0 min(10px, 3vw);
}

/* Common Button Styles */
.power-btn,
.exit-btn,
#homePage,
#back,
#volumeUp,
#volumeDown,
#channelUp,
#channelDown {
    height: var(--button-size);
    width: var(--button-size);
    border-radius: 50%;
    border: none;
}

.power-btn,
#homePage,
#back {
    background: var(--bg-button);
}

.exit-btn {
    background: var(--bg-button-secondary);
    border: 2px solid var(--text-light);
    font-weight: 700;
    font-size: min(18px, 5vw);
    color: var(--text-light);
}

/* Direction Pad */
.direction-container {
    margin: min(12px, 2.5vh) auto;
    position: relative;
    width: var(--dpad-size);
    height: var(--dpad-size);
}

.ok_btn {
    height: 100%;
    width: 100%;
    border-radius: 50%;
    position: absolute;
    background: var(--bg-button-secondary);
    z-index: 0;
    transition: background-color 0.15s ease;
}

.ok-btn {
    height: calc(var(--ok-button-size) * 0.9);
    width: calc(var(--ok-button-size) * 0.9);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9;
    border-radius: 50%;
    border: none;
    background: var(--bg-button);
    color: var(--text-light);
    font-size: min(28px, 7vw);
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Direction Buttons */
#btnUp, #btnDown, #btnLeft, #btnRight {
    width: var(--dir-button-size);
    height: var(--dir-button-size);
    position: absolute;
    background-color: transparent;
    border: none;
    z-index: 2;
    transition: transform 0.15s ease;
}

/* Position for Up and Down buttons - aligned vertically */
#btnUp, #btnDown {
    left: calc(50% - (var(--dir-button-size) / 2));
}

#btnUp {
    top: 8%;
}

#btnDown {
    bottom: 8%;
    transform: rotate(180deg);
}

/* Position for Left and Right buttons - aligned horizontally */
#btnLeft, #btnRight {
    top: calc(50% - (var(--dir-button-size) / 2));
}

#btnLeft {
    left: 8%;
    transform: rotate(-90deg);
}

#btnRight {
    right: 8%;
    transform: rotate(90deg);
}

/* Direction Highlights - adjust to match new button positions */
.direction-highlight {
    position: absolute;
    background: var(--bg-button-active);
    border-radius: 50%;
    width: calc(var(--dir-button-size) * 1.2);
    height: calc(var(--dir-button-size) * 1.2);
    z-index: 1;
    opacity: 0;
    transition: opacity 0.15s ease;
}

#highlightUp, #highlightDown {
    left: calc(50% - (var(--dir-button-size) * 1.2 / 2));
}

#highlightUp {
    top: 8%;
}

#highlightDown {
    bottom: 8%;
}

#highlightLeft, #highlightRight {
    top: calc(50% - (var(--dir-button-size) * 1.2 / 2));
}

#highlightLeft {
    left: 8%;
}

#highlightRight {
    right: 8%;
}

/* Active states for direction buttons */
#btnUp:active {
    transform: scale(0.9);
}

#btnDown:active {
    transform: rotate(180deg) scale(0.9);
}

#btnLeft:active {
    transform: rotate(-90deg) scale(0.9);
}

#btnRight:active {
    transform: rotate(90deg) scale(0.9);
}

/* Channel and Volume Section */
.ch_vol {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 min(10px, 3vw);
    margin-top: min(12px, 2.5vh);
}

.vol_btn, .ch_btn {
    height: var(--vol-ch-height);
    width: var(--vol-ch-width);
    position: relative;
    background: var(--bg-button);
    border-radius: min(40px, 11vw);
}

.home_back {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: var(--vol-ch-height);
    margin: 0;
}

#homePage { margin-top: 5px; }
#back { margin-bottom: 5px; }

#volumeUp, #volumeDown, #channelUp, #channelDown {
    position: absolute;
    left: 5px;
    background: var(--bg-button-secondary);
}

#volumeUp, #channelUp { top: 5px; }
#volumeDown, #channelDown { bottom: 5px; }
#channelDown { transform: rotate(180deg) !important; }

/* Text Styles */
h2 {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: min(16px, 4.5vw);
    font-weight: 400;
    color: var(--text-light);
}

/* Active States */
.power-btn:active,
#homePage:active,
#back:active {
    background: var(--bg-button-active);
}

.ok-btn:active {
    background: var(--bg-button-active);
    transform: translate(-50%, -50%) scale(0.95);
}

/* Direction button active states */
#btnUp:active ~ #highlightUp,
#btnDown:active ~ #highlightDown,
#btnLeft:active ~ #highlightLeft,
#btnRight:active ~ #highlightRight {
    opacity: 1;
    z-index: 2;
}

#volumeDown:active, 
#volumeUp:active, 
#channelDown:active, 
#channelUp:active, 
.exit-btn:active {
    background: var(--bg-button-active-light);
}

/* Dialog Styles */
.popup-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 11;
}

.popup-dialog.show { display: flex; }

.popup-dialog .card {
    background-color: white;
    border-radius: 10px;
    border: 1px solid grey;
    max-width: 300px;
}

.popup-dialog .card .card-title,
.popup-dialog .card .card-body {
    padding: 20px;
    text-align: center;
}

.popup-dialog .card .card-title {
    border-bottom: 1px solid lightgrey;
    font-size: 1.35rem;
    font-weight: bold;
}

/* Loader */
.loader {
    width: 120px;
    height: 120px;
    border: 16px solid #f3f3f3;
    border-top: 16px solid gray;
    border-radius: 50%;
    animation: spin 2s linear infinite;
    z-index: 11;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Media Queries */
/* Large screens */
@media screen and (min-height: 900px) {
    :root {
        --remote-width: min(400px, 90vw);
        --remote-height: min(100vh - 40px, 900px);
        --button-size: min(80px, calc(var(--remote-width) * 0.2));
        --dpad-size: min(300px, calc(var(--remote-width) * 0.8));
        --ok-button-size: min(110px, calc(var(--dpad-size) * 0.36));
        --dir-button-size: min(65px, calc(var(--dpad-size) * 0.21));
        --vol-ch-height: min(240px, calc(var(--remote-height) * 0.3));
    }

    #logo {
        max-height: 10vh;
        margin: -15px auto 10px;
    }
}

/* Medium-large screens */
@media screen and (min-height: 700px) and (max-height: 899px) {
    :root {
        --remote-width: min(360px, 90vw);
        --remote-height: min(100vh - 40px, 800px);
        --button-size: min(70px, calc(var(--remote-width) * 0.2));
        --dpad-size: min(280px, calc(var(--remote-width) * 0.8));
        --ok-button-size: min(100px, calc(var(--dpad-size) * 0.36));
        --dir-button-size: min(60px, calc(var(--dpad-size) * 0.21));
    }

    #logo {
        max-height: 8vh;
        margin: -10px auto 5px;
    }
}

/* Medium screens */
@media screen and (min-height: 600px) and (max-height: 699px) {
    :root {
        --remote-width: min(340px, 90vw);
        --remote-height: min(100vh - 30px, 700px);
        --button-size: min(60px, calc(var(--remote-width) * 0.17));
        --dpad-size: min(240px, calc(var(--remote-width) * 0.7));
        --ok-button-size: min(90px, calc(var(--dpad-size) * 0.36));
        --dir-button-size: min(50px, calc(var(--dpad-size) * 0.21));
        --vol-ch-height: min(200px, calc(var(--remote-height) * 0.28));
    }
    
    .remote-container {
        padding: min(12px, 3vw);
        gap: min(10px, 2vh);
    }

    .direction-container,
    .ch_vol {
        margin: min(10px, 2vh) auto;
    }

    #logo {
        max-height: 7vh;
        margin: -8px auto 2px;
    }

    .power_exit {
        margin-bottom: min(10px, 2vh);
    }
}

/* Small screens */
@media screen and (max-height: 599px) {
    :root {
        --remote-width: min(320px, 90vw);
        --remote-height: min(100vh - 20px, 600px);
        --button-size: min(50px, calc(var(--remote-width) * 0.15));
        --dpad-size: min(200px, calc(var(--remote-width) * 0.6));
        --ok-button-size: min(80px, calc(var(--dpad-size) * 0.36));
        --dir-button-size: min(45px, calc(var(--dpad-size) * 0.21));
        --vol-ch-height: min(180px, calc(var(--remote-height) * 0.25));
    }
    
    .remote-container {
        padding: min(10px, 2.5vw);
        gap: min(8px, 1.5vh);
    }
    
    .direction-container,
    .ch_vol {
        margin: min(8px, 1.5vh) auto;
    }

    #logo {
        max-height: 6vh;
        margin: -5px auto 0;
    }

    .power_exit {
        margin-bottom: min(8px, 1.5vh);
    }

    .ok-btn {
        font-size: min(24px, 6vw);
    }

    .exit-btn {
        font-size: min(16px, 4.5vw);
    }
}

/* Extra small screens */
@media screen and (max-height: 500px) {
    :root {
        --remote-width: min(300px, 90vw);
        --remote-height: min(100vh - 10px, 500px);
        --button-size: min(45px, calc(var(--remote-width) * 0.14));
        --dpad-size: min(180px, calc(var(--remote-width) * 0.55));
        --ok-button-size: min(70px, calc(var(--dpad-size) * 0.36));
        --dir-button-size: min(40px, calc(var(--dpad-size) * 0.21));
        --vol-ch-height: min(160px, calc(var(--remote-height) * 0.25));
    }

    #logo {
        max-height: 5vh;
        margin: -3px auto 0;
        width: min(150px, 45%);
    }
}

/* Width-based adjustments */
@media screen and (max-width: 360px) {
    :root {
        --remote-width: 95vw;
    }
    
    .remote-container {
        padding: 2vw;
    }
}

/* Landscape mode adjustments */
@media screen and (orientation: landscape) and (max-height: 500px) {
    :root {
        --remote-height: 95vh;
    }

    .remote-container {
        padding: 1vh 2vw;
    }

    #logo {
        max-height: 4vh;
        width: min(120px, 40%);
        margin: 0 auto;
    }
} 