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

body, html {
    height: 100%;
    font-family: 'Arial', sans-serif;
    background: #000;
    overflow: hidden;
    /* Improve touch performance on mobile */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Main Display Layout */
.main-display {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
}

.display-content {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Navigation Bar */
.nav-bar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 100;
}

.edit-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-hide {
    background: #ff4444 !important;
    color: #fff !important;
    padding: 8px 12px !important;
    font-size: 16px !important;
    font-weight: bold !important;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-hide:hover {
    background: #cc3333 !important;
}

.display-half {
    height: 100%;
    width: 50%;
    position: relative;
    overflow: hidden;
    border: 1px solid #333;
}

.display-left {
    background: #111;
}

.display-right {
    background: #111;
}

/* Content Display */
.content-display {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.content-display img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.content-display video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Overlay Layer */
.overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.animation-content {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Edit Interface */
.edit-container {
    height: 100vh;
    background: #1a1a1a;
    color: #fff;
    overflow-y: auto;
}

.edit-header {
    background: #2d2d2d;
    padding: 20px;
    border-bottom: 2px solid #444;
}

.edit-header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #00ff88;
}

/* Header Status Grid */
.header-status-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    margin: 20px 0;
}

.display-status {
    background: #333;
    padding: 15px;
    border-radius: 4px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.status-display h4 {
    color: #00ff88;
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: bold;
}

.status-display p {
    margin: 0;
    font-size: 13px;
    color: #ccc;
    line-height: 1.4;
}

.overlay-status {
    color: #ffaa00 !important;
    font-style: italic;
}

/* Connection Status */
.connection-status {
    background: #333;
    padding: 15px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    font-size: 14px;
}

.connection-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
}

.connection-indicator.connected {
    background: #00ff88;
    animation: pulse 2s infinite;
}

.connection-indicator.disconnected {
    background: #ff4444;
}

.edit-content {
    padding: 30px;
    max-width: 800px;
    margin: 0 auto;
}

.control-section {
    background: #2d2d2d;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #444;
}

.control-section h2 {
    color: #00ff88;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

/* Buttons */
.btn {
    background: #00ff88;
    color: #000;
    border: none;
    padding: 12px 20px;
    margin: 5px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    /* Better touch targets */
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

.btn:hover {
    background: #00cc6a;
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-danger {
    background: #ff4444;
    color: #fff;
}

.btn-danger:hover {
    background: #cc3333;
}

.btn-active {
    background: #ffaa00;
    color: #000;
}

/* Controls Grid */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

/* Image/Animation Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.media-item {
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    aspect-ratio: 16/9;
    background: #444;
    /* Better touch targets on mobile */
    min-height: 44px;
    transition: all 0.2s ease;
}

.media-item:hover {
    border-color: #00ff88;
}

.media-item:active {
    transform: scale(0.98);
}

.media-item.active {
    border-color: #ffaa00;
}

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-item .name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 5px;
    font-size: 12px;
    text-align: center;
}

/* Overlay Item Specific Styling */
.overlay-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    text-align: center;
    aspect-ratio: 1;
    min-height: 120px;
}

.overlay-emoji {
    font-size: 3rem;
    margin-bottom: 8px;
    line-height: 1;
}

.overlay-item .name {
    position: static;
    background: none;
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 4px;
    color: #fff;
}

.overlay-item .description {
    font-size: 11px;
    color: #ccc;
    line-height: 1.3;
    margin: 0;
    display: none; /* Hide descriptions on smaller screens by default */
}

/* Timing Controls */
.timing-controls {
    margin: 20px 0;
}

.timing-controls label {
    display: block;
    margin-bottom: 5px;
    color: #ccc;
}

.timing-controls input[type="range"] {
    width: 100%;
    margin-bottom: 10px;
}

.timing-controls input[type="number"] {
    background: #444;
    border: 1px solid #666;
    color: #fff;
    padding: 8px;
    border-radius: 4px;
    width: 100px;
}

/* Connection Status (keeping this as it's still used for WebSocket status) */

/* Navigation */
.nav-bar {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.nav-bar .btn {
    margin-left: 10px;
}

/* Main Display Responsive */
@media (max-width: 768px) {
    /* Stack displays vertically on mobile */
    .main-display {
        flex-direction: column;
    }
    
    .display-half {
        width: 100%;
        height: 50%;
    }
    
    .nav-bar {
        top: 10px;
        right: 10px;
    }
    
    .nav-bar .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .nav-bar {
        top: 5px;
        right: 5px;
    }
    
    .nav-bar .btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* Responsive adjustments for vertical 1440p monitors */
@media (min-height: 1440px) {
    .edit-header h1 {
        font-size: 3rem;
    }
    
    .control-section h2 {
        font-size: 2rem;
    }
    
    .btn {
        padding: 15px 25px;
        font-size: 16px;
    }
    
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* Responsive adjustments for tablets */
@media (max-width: 1024px) {
    .edit-content {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
    }
    
    .edit-header {
        padding: 15px;
    }
    
    .edit-header h1 {
        font-size: 2rem;
    }
    
    .header-status-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .control-section {
        padding: 20px;
    }
    
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    
    .controls-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .timing-controls input[type="number"] {
        width: 80px;
    }
    
    /* Show overlay descriptions on tablets */
    .overlay-item .description {
        display: block;
    }
    
    .overlay-item {
        min-height: 140px;
        padding: 12px;
    }
    
    .overlay-emoji {
        font-size: 2.5rem;
    }
}

/* Responsive adjustments for mobile devices */
@media (max-width: 768px) {
    .edit-header {
        padding: 10px;
    }
    
    .edit-header h1 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    
    .header-status-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin: 15px 0;
    }
    
    .display-status {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px;
    }
    
    .status-display h4 {
        font-size: 13px;
    }
    
    .status-display p {
        font-size: 12px;
    }
    
    .edit-header p {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    .edit-content {
        padding: 15px;
        gap: 15px;
    }
    
    .control-section {
        padding: 15px;
    }
    
    .control-section h2 {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
    
    .control-section h3 {
        font-size: 1rem;
        margin: 15px 0 10px 0;
    }
    
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }
    
    .media-item .name {
        font-size: 10px;
        padding: 3px;
    }
    
    /* Mobile overlay styling - simpler layout */
    .overlay-item {
        min-height: 90px;
        padding: 8px;
        aspect-ratio: 1;
    }
    
    .overlay-emoji {
        font-size: 2rem;
        margin-bottom: 4px;
    }
    
    .overlay-item .name {
        font-size: 11px;
        margin-bottom: 0;
    }
    
    .overlay-item .description {
        display: none; /* Hide on mobile to save space */
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .btn {
        width: 100%;
        padding: 12px;
        font-size: 14px;
        margin: 2px 0;
    }
    
    .timing-controls {
        margin: 15px 0;
    }
    
    .timing-controls input[type="range"] {
        margin-bottom: 8px;
    }
    
    .timing-controls input[type="number"] {
        width: 70px;
        padding: 6px;
        font-size: 12px;
    }
    
    .connection-status {
        padding: 8px 12px;
        font-size: 12px;
        margin: 10px 0;
    }
    
    .sync-status {
        padding: 12px;
        margin-bottom: 15px;
        font-size: 14px;
    }
    
    /* Stack current status side by side on mobile for better space usage */
    .control-section:last-child > div:last-child {
        display: flex;
        gap: 15px;
    }
    
    .control-section:last-child > div:last-child > div {
        flex: 1;
    }
    
    .control-section:last-child h4 {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }
    
    .control-section:last-child p {
        font-size: 0.8rem;
        line-height: 1.2;
    }
}

/* Ultra-small mobile devices */
@media (max-width: 480px) {
    .edit-header h1 {
        font-size: 1.3rem;
    }
    
    .edit-content {
        padding: 10px;
    }
    
    .control-section {
        padding: 12px;
    }
    
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 6px;
    }
    
    .media-item .name {
        font-size: 9px;
        padding: 2px;
    }
    
    /* Ultra-small overlay styling */
    .overlay-item {
        min-height: 70px;
        padding: 6px;
    }
    
    .overlay-emoji {
        font-size: 1.5rem;
        margin-bottom: 2px;
    }
    
    .overlay-item .name {
        font-size: 10px;
    }
    
    /* Reduce section spacing on very small screens */
    .control-section h3[style*="margin-top"] {
        margin-top: 15px !important;
    }
    
    .btn {
        padding: 10px;
        font-size: 12px;
    }
    
    .timing-controls input[type="number"] {
        width: 60px;
    }
    
    /* Make current status stack vertically on very small screens */
    .control-section:last-child > div:last-child {
        flex-direction: column;
        gap: 10px;
    }
}

/* Unified Controls Styles */
.control-section .control-description {
    color: #ccc;
    font-style: italic;
    margin-bottom: 20px;
    font-size: 14px;
}

/* Theme Preview Styles */
.theme-item .theme-preview {
    display: flex;
    gap: 2px;
    margin-bottom: 8px;
}

.theme-preview .preview-left,
.theme-preview .preview-right {
    width: 50%;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .theme-preview .preview-left,
    .theme-preview .preview-right {
        height: 40px;
    }
}

/* Initiative Tracker Styles */
.initiative-tracker-display {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    backdrop-filter: blur(4px);
    z-index: 20;
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: white;
    min-width: 200px;
    max-width: 80%;
    max-height: 70vh;
    overflow-y: auto;
}

.tracker-row {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 18px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tracker-init {
    font-weight: bold;
    color: #ffaa00;
    min-width: 35px;
    text-align: right;
}

.tracker-name {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tracker-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.tracker-hp-container {
    flex: 1;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    overflow: hidden;
    min-width: 100px;
}

.tracker-hp-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff4b2b, #ff416c);
    transition: width 0.5s ease-in-out;
}

.hp-bloodied {
    color: #f5a623;
}

.hp-critical {
    color: #e03e3e;
}

.tracker-slots {
    display: flex;
    gap: 4px;
}

.slot-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4facfe;
    box-shadow: 0 0 5px #00f2fe;
}

.slot-dot.used {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.tracker-conditions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.condition-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(255, 100, 0, 0.3);
    border: 1px solid rgba(255, 100, 0, 0.5);
    color: #ffaa00;
    text-transform: uppercase;
    font-weight: bold;
}

.tracker-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
}
