/* Import de fonte Monospace estilo retro-terminal */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&display=swap');

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

body {
    background-color: #050505;
    color: #00ff66;
    font-family: 'Fira Code', 'Courier New', monospace;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

/* Canvas do Efeito Matrix Rain no Fundo */
#matrix-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    opacity: 0.35;
    pointer-events: none;
}

/* Janela do Terminal */
.terminal-window {
    width: 100%;
    max-width: 900px;
    height: 80vh;
    background-color: rgba(13, 13, 13, 0.92);
    backdrop-filter: blur(6px);
    border: 1px solid #00ff66;
    border-radius: 8px;
    box-shadow: 0 0 25px rgba(0, 255, 102, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
}

/* Barra de Topo */
.terminal-header {
    background-color: #141414;
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #1a3a22;
    position: relative;
}

.terminal-buttons {
    display: flex;
    gap: 8px;
    z-index: 2;
}

.btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.btn-close { background-color: #ff5f56; }
.btn-minimize { background-color: #ffbd2e; }
.btn-maximize { background-color: #27c93f; }

.terminal-title {
    position: absolute;
    width: 100%;
    text-align: center;
    left: 0;
    font-size: 0.85rem;
    color: #00b347;
    pointer-events: none;
    z-index: 1;
}

/* Controlos do Header */
.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2;
}

.lang-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #050505;
    border: 1px solid #00ff66;
    border-radius: 4px;
    padding: 2px 6px;
    height: 32px;
    max-height: 50px;
}

.flag-icon {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
}

.control-select {
    background: transparent;
    color: #00ff66;
    border: none;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
}

.control-select option {
    background: #0d0d0d;
    color: #00ff66;
}

.header-icon-btn {
    width: 32px;
    height: 32px;
    max-width: 50px;
    max-height: 50px;
    background: #050505;
    border: 1px solid #00ff66;
    border-radius: 4px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-icon-btn:hover {
    background: #00ff66;
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.6);
}

.mode-icon-img {
    width: 20px;
    height: 20px;
    max-width: 42px;
    max-height: 42px;
    object-fit: contain;
}

/* Corpo do Terminal */
.terminal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: text;
}

/* Estilização da Scrollbar */
.terminal-body::-webkit-scrollbar {
    width: 8px;
}
.terminal-body::-webkit-scrollbar-track {
    background: #0d0d0d;
}
.terminal-body::-webkit-scrollbar-thumb {
    background: #004d1f;
    border-radius: 4px;
}

/* Histórico de Linhas */
.history-line {
    margin-bottom: 8px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.command-echo {
    color: #00ff66;
    font-weight: 600;
}

.output-text {
    color: #b3ffcc;
    text-shadow: 0 0 3px rgba(0, 255, 102, 0.3);
}

.output-error {
    color: #ff5555;
}

/* Linha de Input do Utilizador */
.input-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.prompt {
    color: #00ff66;
    font-weight: bold;
    white-space: nowrap;
    text-shadow: 0 0 5px rgba(0, 255, 102, 0.5);
}

#terminal-input {
    background: transparent;
    border: none;
    outline: none;
    color: #00ff66;
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
    text-shadow: 0 0 5px rgba(0, 255, 102, 0.5);
    caret-color: #00ff66;
}

/* Estilos da Saída do LS */
.ls-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.ls-dir {
    color: #00ffff !important;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.4);
}

.ls-file {
    color: #b3ffcc;
}

.ls-exe {
    color: #ffd700 !important;
    font-weight: bold;
}

.ls-tag {
    color: #008833;
    font-size: 0.85rem;
    font-weight: bold;
    margin-right: 8px;
}

.ls-long-row {
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}

/* --- Modal / Overlay --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #0d0d0d;
    border: 2px solid #00ff66;
    border-radius: 8px;
    width: 80%;
    height: 85vh;
    max-width: 850px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 255, 102, 0.3);
    overflow: hidden;
    transition: all 0.2s ease-in-out;
}

.modal-header {
    background: #141414;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #00ff66;
    flex-shrink: 0;
}

.modal-title-text {
    color: #00ff66;
    font-weight: bold;
    font-size: 0.9rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: #ff5555;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #ff0000;
}

.modal-body-content {
    padding: 15px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    height: 100%;
    width: 100%;
}

.modal-body-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid #00ff66;
}

.modal-body-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

#preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.2); /* ou 0.5, o valor que preferires */
    backdrop-filter: blur(2px); /* opcional, para dar um desfoque ao fundo */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#preview-modal.hidden {
    display: none !important;
}

/* --- Ações do Header do Modal --- */
.modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-btn {
    background: transparent;
    border: none;
    color: #00ff66;
    font-size: 1.1rem;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 5px;
    border-radius: 3px;
    transition: background 0.2s, color 0.2s;
}

.modal-btn:hover {
    background: rgba(0, 255, 102, 0.2);
    color: #ffffff;
}

/* ESTADO MAXIMIZADO DO MODAL */
.modal-content.maximized {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
}

.modal-content.maximized .modal-body-content {
    height: calc(100vh - 45px);
    padding: 10px;
}

.modal-content.maximized .modal-body-content img {
    max-height: 100%;
}

.modal-content.maximized .modal-body-content iframe {
    height: 100%;
}

.modal-content.maximized .modal-body-content pre {
    max-height: 100% !important;
    height: 100%;
}

/* --- Setas de Navegação do Slideshow --- */
.slideshow-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    position: relative;
    gap: 10px;
}

.slideshow-viewer {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.slide-nav-btn {
    background: rgba(5, 5, 5, 0.7);
    border: 1px solid #00ff66;
    color: #00ff66;
    font-size: 1.5rem;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    user-select: none;
    z-index: 10;
    flex-shrink: 0;
}

.slide-nav-btn:hover {
    background: #00ff66;
    color: #0d0d0d;
    box-shadow: 0 0 12px rgba(0, 255, 102, 0.6);
}

/* ============================================
   Ícone de Partilha (Android Share)
   ============================================ */
.share-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    position: relative;
}

.dot {
    position: absolute;
    width: 5px;
    height: 5px;
    background: currentColor;
    border-radius: 50%;
}

.dot-left {
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
}

.dot-right-top {
    right: 2px;
    top: 3px;
}

.dot-right-bottom {
    right: 2px;
    bottom: 3px;
}

.share-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 8px;
    width: 8px;
    height: 1.5px;
    background: currentColor;
    transform: translateY(-50%) rotate(30deg);
    transform-origin: left center;
}

.share-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 8px;
    width: 8px;
    height: 1.5px;
    background: currentColor;
    transform: translateY(-50%) rotate(-30deg);
    transform-origin: left center;
}

.btn-partilha {
    background: transparent;
    border: 1px solid #444c56;
    border-radius: 6px;
    color: #cdd9e5;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 1.2rem;
}

.btn-partilha:hover {
    background: #373e47;
    border-color: #539bf5;
    color: #539bf5;
}

.btn-partilha:active {
    transform: scale(0.95);
}

/* ============================================
   RODAPÉ (Terminal)
   ============================================ */
.social-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 10px 20px;
    background: rgba(10, 10, 10, 0.85);
    border-top: 1px solid #1a3a22;
    flex-shrink: 0;
    font-size: 0.85rem;
    color: #00ff66;
}

.footer-brand {
    font-family: 'Avenger', 'Fira Code', monospace;
    font-size: 1.4rem;
    letter-spacing: 1px;
    color: #00ff66;
    text-shadow: 0 0 8px rgba(0, 255, 102, 0.3);
}

.footer-contacts {
    font-family: 'Fira Code', monospace;
    font-weight: bold;
    color: #00b347;
}

.footer-icons {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-icons a {
    display: inline-block;
    transition: transform 0.2s ease, filter 0.2s ease;
    line-height: 0;
}

.footer-icons a:hover {
    transform: scale(1.1);
    filter: brightness(1.3);
}

.footer-icons img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: #2d333b;
    padding: 3px;
    object-fit: contain;
    display: block;
}

/* ============================================
   RESPONSIVO PARA ECRÃS PEQUENOS (MOBILE)
   ============================================ */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .terminal-window {
        height: 70vh;
        max-height: 95vh;       /* limita a altura máxima */
        border-radius: 6px;
        max-width: 100%;
    }
    .terminal-header {
        padding: 6px 10px;
    }
    .terminal-title {
        font-size: 0.65rem;
    }
    .terminal-body {
        flex: 1 1 auto;         /* ocupa o espaço disponível, mas pode crescer */
        overflow-y: auto;
        padding: 12px 10px;
    }
    .prompt {
        font-size: 0.8rem;
    }
    #terminal-input {
        font-size: 0.8rem;
    }
    .history-line {
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
    .input-line {
        gap: 6px;
    }
    .header-controls {
        gap: 4px;
    }
    .lang-selector-wrapper {
        height: 28px;
        padding: 2px 4px;
    }
    .flag-icon {
        width: 16px;
        height: 12px;
    }
    .control-select {
        font-size: 0.7rem;
    }
    .header-icon-btn {
        width: 28px;
        height: 28px;
    }
    .mode-icon-img {
        width: 16px;
        height: 16px;
    }
    .modal-content {
        width: 95%;
        height: 90vh;
        max-width: 100%;
        max-height: 90vh;
    }
    .modal-header {
        padding: 6px 10px;
    }
    .modal-title-text {
        font-size: 0.8rem;
    }
    .modal-body-content {
        padding: 10px;
    }
    .slide-nav-btn {
        font-size: 1.2rem;
        padding: 8px 12px;
    }
    #social-footer {
        flex-shrink: 0;
        padding: 8px 12px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        font-size: 0.7rem;
    }
    .footer-brand {
        font-size: 1.1rem;
    }
    .footer-icons img {
        width: 20px;
        height: 20px;
    }
    .btn-partilha {
        padding: 4px 8px;
        font-size: 1rem;
    }
    .share-icon {
        width: 16px;
        height: 16px;
    }
    .dot {
        width: 4px;
        height: 4px;
    }
    .share-icon::before,
    .share-icon::after {
        width: 6px;
        height: 1px;
        left: 6px;
    }
    /* Ajuste para o modal maximizado em mobile */
    .modal-content.maximized .modal-body-content {
        height: calc(100vh - 45px);
    }
}

/* Ajustes para ecrãs muito pequenos (< 480px) */
@media (max-width: 480px) {
    .terminal-title {
        font-size: 0.55rem;
    }
    .prompt {
        font-size: 0.7rem;
    }
    #terminal-input {
        font-size: 0.7rem;
    }
    .history-line {
        font-size: 0.7rem;
    }
    .terminal-body {
        padding: 8px 6px;
    }
    .modal-title-text {
        font-size: 0.7rem;
    }
    .modal-close {
        font-size: 1.2rem;
    }
    .social-footer {
        gap: 4px 8px;
        padding: 6px 8px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    }
    .footer-brand {
        font-size: 0.9rem;
    }
    .footer-icons img {
        width: 18px;
        height: 18px;
    }
    .control-select {
        font-size: 0.6rem;
    }
}

/* Ajuste global para safe area (notch) */
.terminal-window {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.modal-max-icon {
    filter: brightness(0) saturate(100%) invert(49%) sepia(100%) saturate(1000%) hue-rotate(90deg);
}