/* Responsive Mobile Styles for SiteSim */

/* ========================================
   DEFAULT: Hide mobile elements on desktop
   ======================================== */
.mobile-container,
.mobile-tabs {
    display: none;
}

/* ========================================
   MOBILE: Show mobile, hide desktop
   ======================================== */
@media (max-width: 768px) {
    /* Hide desktop layout */
    .desktop-only,
    #main-content {
        display: none !important;
    }

    /* Show mobile layout */
    .mobile-container {
        display: block;
        position: fixed;
        top: 50px;
        left: 0;
        right: 0;
        bottom: 50px;
        background: #1e1e1e;
        overflow: hidden;
    }

    .mobile-tabs {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #1a1a1a;
        border-top: 1px solid #333;
        z-index: 10000;
    }

    /* Fixed header on mobile */
    .main-header {
        display: flex;
        align-items: center;
        padding: 8px 10px;
        flex-wrap: nowrap;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 10001;
        height: 50px;
        box-sizing: border-box;
    }

    .main-header img {
        width: 30px;
        height: 30px;
    }

    .main-header_heading {
        font-size: 16px !important;
        margin: 0 5px;
        padding: 0 !important;
        position: static !important;
        top: auto !important;
    }

    .main-header h2 {
        display: none !important;
    }

    .header-btn {
        padding: 8px 10px !important;
        font-size: 12px !important;
        width: auto !important;
    }

    .header-btn .fa {
        font-size: 16px !important;
    }

    .header-btn .web-extra,
    .header-btn br {
        display: none;
    }

    /* Prevent body scroll */
    body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}

/* ========================================
   Mobile Tab Bar Styles
   ======================================== */
.mobile-tabs ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    justify-content: space-around;
}

.mobile-tabs li {
    flex: 1;
    text-align: center;
}

.mobile-tabs a {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    color: #888;
    text-decoration: none;
    font-size: 10px;
    transition: all 0.2s;
}

.mobile-tabs a i {
    font-size: 18px;
    margin-bottom: 2px;
}

.mobile-tabs a.active {
    color: #0066cc;
    background: #252525;
}

.mobile-tabs a:hover,
.mobile-tabs a:active {
    color: #aaa;
}

/* ========================================
   Mobile Panel Styles
   ======================================== */
.mobile-panel {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1e1e1e;
    overflow: auto;
}

.mobile-panel.active {
    display: flex;
    flex-direction: column;
}

.mobile-panel .code-editor {
    flex: 1;
    height: 100%;
    width: 100%;
}

.mobile-panel .CodeMirror {
    height: 100% !important;
}

/* ========================================
   Mobile Details Panel
   ======================================== */
.mobile-details {
    padding: 15px;
}

.mobile-details .form-group {
    margin-bottom: 15px;
}

.mobile-details label {
    display: block;
    color: #aaa;
    font-size: 12px;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-details input,
.mobile-details textarea {
    width: 100%;
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 12px;
    color: #e0e0e0;
    font-size: 16px; /* Prevents iOS zoom */
    box-sizing: border-box;
}

.mobile-details textarea {
    min-height: 100px;
    resize: vertical;
}

.mobile-details input:focus,
.mobile-details textarea:focus {
    outline: none;
    border-color: #0066cc;
}

/* ========================================
   Mobile Preview Panel
   ======================================== */
.mobile-preview {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
}

.mobile-preview .preview-toolbar {
    display: flex;
    padding: 8px;
    background: #252525;
    border-bottom: 1px solid #333;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.mobile-preview .preview-toolbar button {
    background: #333;
    border: none;
    border-radius: 4px;
    color: #aaa;
    padding: 10px 14px;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
}

.mobile-preview .preview-toolbar button:active {
    background: #444;
}

.mobile-preview .preview-toolbar button:disabled {
    opacity: 0.4;
}

.mobile-preview .preview-toolbar input {
    flex: 1;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 10px;
    color: #e0e0e0;
    font-size: 14px;
    min-width: 0;
}

.mobile-preview .preview-frame {
    flex: 1;
    border: none;
    background: white;
    width: 100%;
}

/* Loading spinner overlay */
.mobile-preview .loading-overlay {
    position: absolute;
    top: 50px; /* below toolbar */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(30, 30, 30, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.mobile-preview .loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #333;
    border-top-color: #0066cc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* History dropdown */
.history-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 8px;
    min-width: 250px;
    max-width: 300px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    display: none;
}

.history-dropdown.show {
    display: block;
}

.history-dropdown-item {
    padding: 12px 14px;
    color: #ccc;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid #3a3a3a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-dropdown-item:last-child {
    border-bottom: none;
}

.history-dropdown-item:hover,
.history-dropdown-item:active {
    background: #3a3a3a;
    color: #fff;
}

.history-dropdown-item.current {
    background: #0066cc;
    color: #fff;
}

.history-dropdown-empty {
    padding: 20px;
    color: #666;
    text-align: center;
    font-size: 13px;
}

/* Button wrapper for history dropdown positioning */
.preview-toolbar .nav-btn-wrapper {
    position: relative;
}

/* ========================================
   Mobile Agent Panel
   ======================================== */
.mobile-panel .agent-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.mobile-panel .agent-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.mobile-panel .agent-input-area {
    padding: 10px;
    background: #252525;
    border-top: 1px solid #333;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.mobile-panel #mobile-agent-input {
    flex: 1;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 12px;
    color: #e0e0e0;
    font-size: 16px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
}

.mobile-panel .btn-agent-send {
    background: #0066cc;
    border: none;
    border-radius: 8px;
    color: white;
    padding: 12px 16px;
    min-width: 44px;
    min-height: 44px;
}

/* ========================================
   Mobile Files Panel
   ======================================== */
.mobile-panel .files-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.mobile-panel .files-toolbar {
    display: flex;
    padding: 8px;
    background: #252525;
    border-bottom: 1px solid #333;
    gap: 6px;
    flex-shrink: 0;
}

.mobile-panel .file-dropzone {
    margin: 10px;
    padding: 30px 20px;
    border: 2px dashed #444;
    border-radius: 8px;
    text-align: center;
    color: #666;
    flex-shrink: 0;
}

.mobile-panel .file-dropzone i {
    font-size: 32px;
    margin-bottom: 10px;
    display: block;
}

.mobile-panel .file-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* ========================================
   Touch-friendly adjustments
   ======================================== */
@media (max-width: 768px) {
    .btn-code-action,
    .btn-file-action,
    .btn-files {
        min-height: 44px;
        min-width: 44px;
        padding: 12px;
    }

    .file-item {
        padding: 14px 12px;
    }

    .chat-message {
        max-width: 90%;
    }
}

/* ========================================
   Landscape orientation adjustments
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-tabs a {
        padding: 4px;
    }

    .mobile-tabs a i {
        font-size: 16px;
    }

    .mobile-tabs a span {
        display: none;
    }

    .mobile-container {
        bottom: 40px;
    }

    .main-header {
        height: 40px;
    }

    .mobile-container {
        top: 40px;
    }
}

/* ========================================
   Code blocks in chat
   ======================================== */
.code-block {
    background: #1a1a1a;
    border-radius: 8px;
    margin: 8px 0;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #252525;
    border-bottom: 1px solid #333;
}

.code-lang {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
}

.code-actions {
    display: flex;
    gap: 6px;
}

.btn-code-action {
    background: #333;
    border: none;
    border-radius: 4px;
    color: #aaa;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}

.btn-apply-code {
    background: #1a5c1a;
    color: #8f8;
}

.code-block pre {
    margin: 0;
    padding: 12px;
    overflow-x: auto;
}

.code-block code {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    color: #d4d4d4;
}

/* Chat messages */
.chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    margin-bottom: 10px;
}

.chat-message.user {
    align-self: flex-end;
    background: #0066cc;
    color: white;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.chat-message.assistant {
    align-self: flex-start;
    background: #2d2d2d;
    color: #e0e0e0;
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px !important;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* No files message */
.no-files {
    text-align: center;
    color: #666;
    padding: 30px 20px;
    font-size: 14px;
}

/* ========================================
   Mobile Modal Styles (Share Dialog, etc)
   ======================================== */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px;
        width: calc(100% - 20px);
        max-width: none;
    }

    .modal-dialog.modal-lg {
        width: calc(100% - 20px);
    }

    .modal-content {
        border-radius: 12px;
    }

    .modal-body {
        padding: 15px;
    }

    .modal-body h3 {
        font-size: 14px;
        margin: 10px 0 5px 0;
        color: #aaa;
    }

    .modal-body input.webfiddle-share-link {
        width: 100%;
        padding: 12px;
        font-size: 14px;
        border-radius: 6px;
        border: 1px solid #444;
        background: #2d2d2d;
        color: #e0e0e0;
        box-sizing: border-box;
    }

    .modal-body .mm-sharing-btns {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        margin: 10px 0 15px 0;
    }

    .modal-body .mm-share-btn {
        font-size: 32px;
        margin: 0;
    }

    .modal-header {
        padding: 10px 15px;
        border-bottom: 1px solid #333;
    }

    .modal-header .close {
        font-size: 28px;
        opacity: 0.7;
    }

    /* Ensure modal appears above everything on mobile */
    .modal {
        z-index: 20000;
    }

    .modal-backdrop {
        z-index: 19999;
    }
}
