/**
 * Qarlos CSS - Compatible con webOS 1.x, 2.x, 3.x y superiores
 */

* {
    margin: 0;
    padding: 0;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background: #1a1a2e; /* Fallback solid color */
    background: -webkit-linear-gradient(315deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    background: -moz-linear-gradient(315deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    background: -o-linear-gradient(315deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #fff;
    overflow: hidden;
    width: 1920px;
    height: 1080px;
}

#app-container {
    width: 100%;
    height: 100%;
    padding: 40px 60px;
    /* Flexbox con fallbacks */
    display: block;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
}

/* Header */
#header {
    text-align: center;
    margin-bottom: 40px;
    height: 100px;
}

#header h1 {
    font-size: 64px;
    font-weight: 300;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
    margin-bottom: 10px;
}

#api-status {
    font-size: 24px;
    color: #888;
}

#api-status.connected {
    color: #4ade80;
}

#api-status.error {
    color: #f87171;
}

/* Main Content */
#main-content {
    /* Fallback: usar table layout para compatibilidad */
    display: table;
    width: 100%;
    height: 750px;
    table-layout: fixed;
}

/* Apps Panel */
#apps-panel {
    display: table-cell;
    vertical-align: top;
    width: 500px;
    background: #1e2538; /* Fallback solid */
    background: rgba(255,255,255,0.05);
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px;
    padding: 30px;
    border: 2px solid #2a3348;
    border: 2px solid rgba(255,255,255,0.1);
}

#apps-panel h2 {
    font-size: 32px;
    font-weight: 400;
    margin-bottom: 20px;
    color: #94a3b8;
}

#apps-list {
    list-style: none;
    max-height: 600px;
    overflow-y: auto;
}

#apps-list li {
    padding: 20px 30px;
    margin-bottom: 10px;
    background: #1e2538;
    background: rgba(255,255,255,0.05);
    -webkit-border-radius: 12px;
    -moz-border-radius: 12px;
    border-radius: 12px;
    font-size: 28px;
    cursor: pointer;
    border: 2px solid transparent;
    /* Transition con prefijos */
    -webkit-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    -o-transition: all 0.2s ease;
    transition: all 0.2s ease;
}

#apps-list li.refresh-btn {
    background: rgba(229, 57, 53, 0.3);
    border-color: #e53935;
    color: #fff;
}

#apps-list li.refresh-btn .refresh-icon {
    display: inline-block;
    margin-right: 10px;
}

#apps-list li.refresh-btn.focused {
    background: #e53935;
    border-color: #ff6659;
    -webkit-transform: scale(1.02);
    -moz-transform: scale(1.02);
    -ms-transform: scale(1.02);
    -o-transform: scale(1.02);
    transform: scale(1.02);
}

#apps-list li:hover,
#apps-list li.focused {
    background: #2a3d6e;
    background: rgba(67, 97, 238, 0.3);
    border-color: #4361ee;
    /* Transform con prefijos */
    -webkit-transform: scale(1.02);
    -moz-transform: scale(1.02);
    -ms-transform: scale(1.02);
    -o-transform: scale(1.02);
    transform: scale(1.02);
}

#apps-list li.selected {
    background: #3a4d8e;
    background: rgba(67, 97, 238, 0.5);
    border-color: #4361ee;
}

/* Spacer between panels */
#apps-panel + #environments-panel {
    border-left: 60px solid transparent;
}

/* Environments Panel */
#environments-panel {
    display: table-cell;
    vertical-align: top;
    background: #1e2538;
    background: rgba(255,255,255,0.05);
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px;
    padding: 30px;
    border: 2px solid #2a3348;
    border: 2px solid rgba(255,255,255,0.1);
}

#environments-panel h2 {
    font-size: 32px;
    font-weight: 400;
    margin-bottom: 10px;
    color: #94a3b8;
}

#selected-app-name {
    font-size: 24px;
    color: #4361ee;
    margin-bottom: 15px;
    min-height: 30px;
}

/* Tabs Bar */
#tabs-bar {
    overflow-x: auto;
    overflow-y: hidden;
    margin-bottom: 20px;
    padding-bottom: 10px;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#tabs-bar::-webkit-scrollbar {
    display: none;
}

.tab-item {
    display: inline-block;
    vertical-align: middle;
    padding: 12px 20px;
    margin-right: 10px;
    background: #1e2538;
    background: rgba(255,255,255,0.05);
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    border: 2px solid transparent;
    white-space: nowrap;
    -webkit-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    -o-transition: all 0.2s ease;
    transition: all 0.2s ease;
}

.tab-item.selected {
    background: #2a3d6e;
    background: rgba(67, 97, 238, 0.3);
    border-color: #4361ee;
}

.tab-item.focused {
    background: #4a4520;
    background: rgba(250, 204, 21, 0.3);
    border-color: #facc15;
    -webkit-transform: scale(1.05);
    -moz-transform: scale(1.05);
    -ms-transform: scale(1.05);
    -o-transform: scale(1.05);
    transform: scale(1.05);
}

.tab-icon {
    display: inline-block;
    font-size: 24px;
    margin-right: 8px;
    vertical-align: middle;
}

.tab-title {
    display: inline-block;
    font-size: 20px;
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.tab-count {
    display: inline-block;
    font-size: 16px;
    color: #94a3b8;
    margin-left: 8px;
    vertical-align: middle;
}

#environments-list {
    list-style: none;
    max-height: 450px;
    overflow-y: auto;
}

#environments-list li {
    padding: 25px 35px;
    margin-bottom: 15px;
    background: #1e2538;
    background: rgba(255,255,255,0.05);
    -webkit-border-radius: 12px;
    -moz-border-radius: 12px;
    border-radius: 12px;
    cursor: pointer;
    border: 2px solid transparent;
    -webkit-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    -o-transition: all 0.2s ease;
    transition: all 0.2s ease;
    /* Layout para nombre y URL */
    overflow: hidden;
}

#environments-list li .env-name {
    font-size: 32px;
    font-weight: 500;
    display: block;
    float: left;
}

#environments-list li .env-url {
    font-size: 20px;
    color: #64748b;
    max-width: 700px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    float: right;
    line-height: 40px;
}

#environments-list li:hover,
#environments-list li.focused {
    background: #264a3a;
    background: rgba(74, 222, 128, 0.2);
    border-color: #4ade80;
    -webkit-transform: scale(1.02);
    -moz-transform: scale(1.02);
    -ms-transform: scale(1.02);
    -o-transform: scale(1.02);
    transform: scale(1.02);
}

#environments-list li.focused .env-name {
    color: #4ade80;
}

/* Clear floats */
#environments-list li:after {
    content: "";
    display: table;
    clear: both;
}

/* Footer */
#footer {
    text-align: center;
    padding: 30px 0;
    border-top: 1px solid #2a3348;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 30px;
    height: 90px;
}

.key-hint {
    display: inline-block;
    margin: 0 30px;
    font-size: 22px;
    color: #94a3b8;
    vertical-align: middle;
}

.key-hint .key {
    display: inline-block;
    background: #2a3348;
    background: rgba(255,255,255,0.1);
    padding: 8px 16px;
    -webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
    font-weight: 600;
    color: #fff;
    min-width: 50px;
    text-align: center;
    margin-right: 10px;
    vertical-align: middle;
}

.key-hint .key.red-key {
    background: #e53935;
    color: #fff;
}

/* Offline Message */
#offline-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    display: none;
}

.offline-content {
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    -moz-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    -o-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    text-align: center;
}

.offline-content img {
    width: 150px;
    margin-bottom: 40px;
}

.offline-content h2 {
    font-size: 48px;
    margin-bottom: 20px;
}

.offline-content p {
    font-size: 28px;
    color: #94a3b8;
}

/* Loading */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    display: none;
}

.spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -70px;
    margin-left: -40px;
    width: 80px;
    height: 80px;
    border: 6px solid #2a3348;
    border: 6px solid rgba(255,255,255,0.1);
    border-top-color: #4361ee;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border-radius: 50%;
    -webkit-animation: spin 1s linear infinite;
    -moz-animation: spin 1s linear infinite;
    -o-animation: spin 1s linear infinite;
    animation: spin 1s linear infinite;
}

@-webkit-keyframes spin {
    to { -webkit-transform: rotate(360deg); }
}
@-moz-keyframes spin {
    to { -moz-transform: rotate(360deg); }
}
@-o-keyframes spin {
    to { -o-transform: rotate(360deg); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading p {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: 30px;
    -webkit-transform: translateX(-50%);
    -moz-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    -o-transform: translateX(-50%);
    transform: translateX(-50%);
    font-size: 28px;
    color: #fff;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px;
    color: #64748b;
    font-size: 24px;
}

/* Responsive for 720p */
@media screen and (max-width: 1280px) {
    body {
        width: 1280px;
        height: 720px;
    }

    #app-container {
        padding: 25px 40px;
    }

    #header {
        height: 70px;
        margin-bottom: 25px;
    }

    #header h1 {
        font-size: 42px;
    }

    #api-status {
        font-size: 18px;
    }

    #main-content {
        height: 500px;
    }

    #apps-panel {
        width: 350px;
        padding: 20px;
    }

    #apps-panel + #environments-panel {
        border-left-width: 40px;
    }

    #apps-panel h2,
    #environments-panel h2 {
        font-size: 24px;
        margin-bottom: 15px;
    }

    #apps-list {
        max-height: 400px;
    }

    #apps-list li {
        padding: 15px 20px;
        font-size: 20px;
        margin-bottom: 8px;
    }

    #environments-panel {
        padding: 20px;
    }

    #environments-list {
        max-height: 350px;
    }

    #selected-app-name {
        font-size: 18px;
        margin-bottom: 15px;
    }

    #environments-list li {
        padding: 18px 25px;
        margin-bottom: 10px;
    }

    #environments-list li .env-name {
        font-size: 24px;
    }

    #environments-list li .env-url {
        font-size: 16px;
        max-width: 450px;
        line-height: 30px;
    }

    /* Tabs responsive */
    #tabs-bar {
        margin-bottom: 15px;
    }

    .tab-item {
        padding: 8px 14px;
        margin-right: 8px;
    }

    .tab-icon {
        font-size: 18px;
        margin-right: 6px;
    }

    .tab-title {
        font-size: 16px;
        max-width: 150px;
    }

    .tab-count {
        font-size: 14px;
        margin-left: 6px;
    }

    #environments-list {
        max-height: 280px;
    }

    #footer {
        height: 70px;
        padding: 20px 0;
        margin-top: 20px;
    }

    .key-hint {
        font-size: 16px;
        margin: 0 20px;
    }

    .key-hint .key {
        padding: 6px 12px;
        font-size: 14px;
        margin-right: 8px;
    }
}
