/* ==========================================================================
   MindVault Main Stylesheet
   ========================================================================== */

/* --- Global Styles --- */
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0; 
    padding: 1em; 
    background: #f4f7f6;
    color: #333;
    line-height: 1.6;
    min-height: 100vh; 
    display: flex;
    flex-direction: column;
}

.container { 
    max-width: 600px; 
    margin: 0 auto; 
    padding: 2em; 
    background: #ffffff; 
    border-radius: 12px; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    width: 100%;
    box-sizing: border-box;
    flex: 1; 
    margin-bottom: 0; 
}

/* Headings */
h1 {
    text-align: center;
    color: #111;
    margin-top: 0;
    margin-bottom: 1em;
    font-weight: 800;
}

h2 {
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
    margin-bottom: 1.5em;
    font-weight: 700;
    color: #2c3e50;
}

/* --- Form Styles --- */
form div {
    margin-bottom: 1.5em;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5em;
    font-size: 0.9em;
    color: #444;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.9em;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
    outline: none;
}

/* --- BUTTONS & ACTIONS --- */

/* 1. Botão de Submissão Padrão */
form:not(.inline-form) button[type="submit"] {
    width: 100%;
    padding: 1em;
    background-color: #2a2a2a;
    color: white;
    font-weight: bold;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}
form:not(.inline-form) button[type="submit"]:hover {
    background-color: #444;
}

/* 2. Botão Primário (Azul) */
.button-primary {
    display: inline-block;
    background-color: #007bff;
    color: white;
    padding: 0.7em 1.4em;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.1s;
    border: none;
    cursor: pointer;
    font-size: 1em;
    text-align: center;
    box-sizing: border-box; 
}
.button-primary:hover {
    background-color: #0056b3;
    text-decoration: none;
    color: white;
    transform: translateY(-1px);
}

/* 3. CTA Button */
.cta-button {
    display: block;
    width: 100%;
    text-align: center;
    background-color: #007bff;
    color: white;
    padding: 1.1em;
    border-radius: 10px;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1em;
    margin-top: 2em;
    box-shadow: 0 4px 12px rgba(0,123,255,0.2);
    transition: background-color 0.2s, transform 0.1s;
    box-sizing: border-box; 
}
.cta-button:hover {
    background-color: #0069d9;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,123,255,0.3);
}

/* 4. Botão Danger Outline */
.button-danger-outline {
    background: transparent;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 0.5em 1em;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    text-decoration: none;
    transition: all 0.2s;
}
.button-danger-outline:hover {
    background: #dc3545;
    color: white;
}

/* 5. Botão de Ícone de Ação (Lixo no Header) */
.action-icon-btn {
    background: transparent !important;
    border: none !important;
    width: auto !important;
    padding: 8px !important;
    margin: 0 !important;
    font-size: 1.4em;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s, opacity 0.2s;
    color: #dc3545; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    /* UX: Visibilidade total por defeito */
    opacity: 1; 
}
.action-icon-btn:hover {
    /* UX: Fica ligeiramente mais claro no hover */
    opacity: 0.7;
    background-color: rgba(220, 53, 69, 0.05) !important;
    transform: scale(1.1);
}

/* 6. Links de Ícone */
.icon-link {
    text-decoration: none !important;
    font-size: 1.5em;
    line-height: 1;
    padding: 5px;
    display: inline-block;
    transition: transform 0.2s, opacity 0.2s;
    border: none;
    background: transparent;
    /* UX: Visibilidade total por defeito */
    opacity: 1;
}
.icon-link:hover {
    transform: scale(1.15);
    /* UX: Fica ligeiramente mais claro no hover */
    opacity: 0.7;
}
.icon-link.neutral { color: #6c757d; }
.icon-link.danger { color: #dc3545; }
.icon-link.primary { color: #007bff; }


/* --- Flash Messages --- */
.error, .success {
    padding: 1em;
    border-radius: 8px;
    margin-bottom: 2em;
    box-sizing: border-box;
    width: 100%;
    font-weight: 500;
    display: flex;
    align-items: center;
}
.error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}
.success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

/* --- Dashboard --- */

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2em;
    border-bottom: 1px solid #eee;
    padding-bottom: 1em;
}
.dashboard-header h2 {
    margin: 0;
    border: none;
    padding: 0;
    font-size: 1.5em;
}

/* Project Grid (Mobile Friendly Fix) */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 1.5em;
    margin-bottom: 3em;
}

a.project-card {
    display: block;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.5em;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    word-break: break-word; 
}
a.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    border-color: #3b82f6;
}

a.project-card h3 {
    margin-top: 0;
    font-size: 1.25em;
    color: #1f2937;
    margin-bottom: 0.5em;
    font-weight: 700;
}
a.project-card:hover h3 { color: #2563eb; }

.project-description {
    color: #6b7280;
    font-size: 0.95em;
    line-height: 1.5;
    margin-bottom: 1.5em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-meta {
    font-size: 0.85em;
    color: #9ca3af;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f3f4f6;
    padding-top: 1em;
    font-weight: 500;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4em 2em;
    background: #f9fafb;
    border-radius: 12px;
    border: 2px dashed #e5e7eb;
    color: #6b7280;
}

/* --- Project View Layout --- */
.top-nav {
    margin-bottom: 1.5em;
    display: flex;
    align-items: center;
}

.project-view-header {
    background: white;
    padding: 0; 
    margin-bottom: 2em;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5em;
    border-bottom: 1px solid #eee;
    padding-bottom: 1em;
}

.project-title h2 { 
    margin: 0 0 0.2em 0; 
    font-size: 1.8em; 
    color: #111;
    line-height: 1.2;
    border: none;
}

.project-meta-badges { 
    font-size: 0.85em; 
    color: #888; 
    font-weight: 500;
}

.encrypted-content {
    background: #f8fafc;
    padding: 1.5em;
    border-radius: 10px;
    border-left: 4px solid #10b981; 
    color: #334155;
    line-height: 1.7;
    font-size: 1em;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    word-wrap: break-word; /* Previne overflow de texto encriptado */
}

/* --- Records List --- */
.records-section { margin-top: 3em; }

.records-section h3 {
    font-size: 1.1em;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1.5em;
    border-bottom: none;
}

.record-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.5em;
    margin-bottom: 1.5em;
    transition: box-shadow 0.2s;
    position: relative;
    word-wrap: break-word;
}
.record-item:hover { 
    box-shadow: 0 4px 12px rgba(0,0,0,0.05); 
    border-color: #cbd5e1;
}

.record-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-bottom: 1em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid #f1f5f9;
}
.record-header h4 { 
    margin: 0; 
    font-size: 1.2em; 
    font-weight: 700;
    color: #1e293b; 
}

.record-preview { 
    color: #475569; 
    margin-bottom: 1em; 
    line-height: 1.6; 
}

.record-actions { display: flex; gap: 15px; }

/* Icon Button Reset */
.icon-button, .icon-button-danger {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    text-decoration: none;
    padding: 0;
    /* UX: Visibilidade total por defeito */
    opacity: 1;
    transition: opacity 0.2s;
}
/* UX: Fica mais claro no hover */
.icon-button:hover, .icon-button-danger:hover { opacity: 0.7; }
.inline-form { display: inline; }

/* 2FA Image */
img[alt="QR Code 2FA"] {
    display: block;
    margin: 2em auto;
    max-width: 250px;
    height: auto;
    border: 8px solid white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border-radius: 4px;
    width: 100%; /* Mobile fix */
}
.secret-key-backup {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 1.1em;
    background: #f3f4f6;
    padding: 1em;
    border-radius: 6px;
    color: #dc2626;
    font-weight: bold;
    word-wrap: break-word;
    text-align: center;
    border: 1px dashed #fca5a5;
}

/* Utilitários */
.text-danger { color: #dc3545; text-decoration: none; }
.text-muted { color: #6c757d; text-decoration: none; }
.container-narrow { max-width: 500px; margin: 0 auto; }
.required { color: #dc3545; margin-left: 2px; }

/* --- Footer --- */
.app-footer {
    text-align: center;
    font-size: 0.85em;
    color: #9ca3af;
    margin-top: auto; /* Empurra para o fim do container flex */
    padding-top: 2em;
    padding-bottom: 1em;
}