/**
 * Código Postal Cabo Verde - Estilos CSS
 * Ficheiro: css/styles.css
 * Ligado a: index.html
 */

/* ============== CSS RESET & BASE ============== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --secondary: #64748b;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ============== HEADER ============== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 15px 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; }

.logo { display: flex; align-items: center; gap: 10px; font-size: 1.5rem; font-weight: 700; }
.logo-icon { width: 32px; height: 32px; }

.nav { display: flex; gap: 5px; flex-wrap: wrap; }
.nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    transition: all 0.2s;
}
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,0.2); color: white; }

/* ============== MAIN ============== */
.main { flex: 1; padding: 40px 0; }
.section { display: none; }
.section.active { display: block; }

/* ============== HERO ============== */
.hero { text-align: center; margin-bottom: 40px; }
.hero h1 { font-size: 2.5rem; color: var(--primary-dark); margin-bottom: 10px; }
.hero p { color: var(--text-light); font-size: 1.1rem; }

/* ============== STATS ============== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 40px; }

.stat-card {
    background: var(--bg-white);
    padding: 25px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }

.stat-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 15px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon svg { width: 24px; height: 24px; stroke: white; }
.stat-value { font-size: 2.5rem; font-weight: 700; color: var(--primary-dark); }
.stat-label { color: var(--text-light); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; }

/* ============== SEARCH BOX ============== */
.quick-search {
    background: var(--bg-white);
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.quick-search h2 { margin-bottom: 20px; color: var(--primary-dark); }
.search-box { display: flex; gap: 10px; flex-wrap: wrap; }
.search-box input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}
.search-box input:focus { outline: none; border-color: var(--primary-light); }

/* ============== BUTTONS ============== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: linear-gradient(135deg, var(--primary-light), var(--primary)); color: white; }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); transform: translateY(-2px); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 0.875rem; }

/* ============== FILTER GROUP ============== */
.filter-group {
    background: var(--bg-white);
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}
.filter-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 20px; }
.filter-item label { display: block; margin-bottom: 5px; font-weight: 500; color: var(--text); }
.filter-item input, .filter-item select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--bg-white);
}
.filter-item input:focus, .filter-item select:focus { outline: none; border-color: var(--primary-light); }

/* ============== DROPDOWN ============== */
.dropdown {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 40px !important;
    cursor: pointer;
}

/* ============== RESULTS ============== */
.results-container { margin-top: 30px; }
.results-container.hidden { display: none; }

.results-table {
    width: 100%;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.results-table table { width: 100%; border-collapse: collapse; }
.results-table th, .results-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.results-table th { background: var(--primary-dark); color: white; font-weight: 600; }
.results-table tr:hover { background: #f1f5f9; }
.results-table .actions { display: flex; gap: 5px; }

.codigo-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.875rem;
}
.no-results { text-align: center; padding: 40px; color: var(--text-light); }

/* ============== CRUD ============== */
.crud-container { display: grid; grid-template-columns: 400px 1fr; gap: 30px; }

.crud-form {
    background: var(--bg-white);
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    height: fit-content;
}
.crud-form h3 {
    margin-bottom: 20px;
    color: var(--primary-dark);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; }
.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary-light); }
.form-group small { color: var(--text-light); font-size: 0.8rem; }
.form-actions { display: flex; gap: 10px; }

.crud-list {
    background: var(--bg-white);
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.crud-list h3 { margin-bottom: 20px; color: var(--primary-dark); }
.table-container { overflow-x: auto; max-height: 500px; overflow-y: auto; }

/* ============== EXPORT ============== */
.export-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 30px; margin-bottom: 40px; }

.export-card {
    background: var(--bg-white);
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.export-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }

.export-icon {
    width: 70px;
    height: 70px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.export-icon svg { width: 32px; height: 32px; stroke: white; }
.export-icon.excel { background: linear-gradient(135deg, #059669, #047857); }
.export-icon.json { background: linear-gradient(135deg, #d97706, #b45309); }
.export-card h3 { margin-bottom: 10px; color: var(--text); }
.export-card p { color: var(--text-light); font-size: 0.9rem; }

/* ============== API DOCS ============== */
.api-docs {
    background: var(--bg-white);
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.api-docs h3 { margin-bottom: 20px; color: var(--primary-dark); }
.api-list { display: flex; flex-direction: column; gap: 10px; }
.api-item { display: flex; align-items: center; gap: 15px; padding: 12px; background: var(--bg); border-radius: var(--radius); flex-wrap: wrap; }
.method { padding: 4px 10px; border-radius: 4px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.method.get { background: #059669; color: white; }
.method.post { background: #3b82f6; color: white; }
.method.put { background: #d97706; color: white; }
.method.delete { background: #dc2626; color: white; }
.api-item code {
    font-family: 'Monaco', 'Consolas', monospace;
    background: #1e293b;
    color: #38bdf8;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.875rem;
}
.api-item .desc { color: var(--text-light); font-size: 0.875rem; }

/* ============== FOOTER ============== */
.footer { background: var(--primary-dark); color: white; padding: 20px 0; text-align: center; }
.footer-info { font-size: 0.875rem; opacity: 0.7; margin-top: 5px; }

/* ============== TOAST ============== */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 15px 25px;
    border-radius: var(--radius);
    color: white;
    font-weight: 500;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

/* ============== RESPONSIVE ============== */
@media (max-width: 768px) {
    .header-content { justify-content: center; }
    .hero h1 { font-size: 1.8rem; }
    .crud-container { grid-template-columns: 1fr; }
    .filter-row { grid-template-columns: 1fr; }
    .results-table { font-size: 0.875rem; }
    .results-table th, .results-table td { padding: 8px 10px; }
}
