/*
 * Pitié app component styles.
 * Everything is scoped under .pitie-app so this stylesheet cannot leak
 * onto (or be overridden by) a host page's own h2/table/select/input/etc.
 * Requires assets/css/theme.css to be linked first (design tokens).
 * Known limitation: element *ids* referenced from pitie-app.js (#mobile-menu,
 * #search-results, ...) are still page-global — don't reuse those exact ids
 * elsewhere on a host page.
 */
.pitie-app,
.pitie-app * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.pitie-app {
    font-family: var(--pitie-font-family);
    background-color: var(--pitie-gray-50);
    line-height: 1.6;
    color: var(--pitie-gray-800);
}

.pitie-app .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header Styles */
.pitie-app header {
    background-color: white;
    box-shadow: var(--pitie-shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.pitie-app .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
}

.pitie-app .logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--pitie-blue);
}

/* Navigation */
.pitie-app nav {
    display: flex;
    gap: 32px;
}

.pitie-app .nav-link {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--pitie-gray-700);
    text-decoration: none;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.pitie-app .nav-link:hover {
    color: var(--pitie-blue-dark);
}

.pitie-app .nav-link.active {
    color: var(--pitie-blue);
    border-bottom-color: var(--pitie-blue);
}

/* Mobile Menu Button */
.pitie-app .mobile-menu-button {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.pitie-app .mobile-menu-button svg {
    width: 24px;
    height: 24px;
    stroke: var(--pitie-blue);
}

/* Mobile Menu */
.pitie-app #mobile-menu {
    display: none;
    padding: 8px 12px 12px;
}

.pitie-app #mobile-menu.show {
    display: block;
}

.pitie-app #mobile-menu a {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--pitie-gray-700);
    font-weight: 500;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

.pitie-app #mobile-menu a:hover {
    background-color: var(--pitie-gray-100);
}

.pitie-app #mobile-menu a.active {
    color: var(--pitie-blue);
    background-color: rgba(0, 85, 164, 0.1);
}

/* Main Content */
.pitie-app main {
    padding: 48px 0;
}

.pitie-app .page-section {
    display: none;
}

.pitie-app .page-section.active {
    display: block;
}

/* Typography */
.pitie-app h2 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--pitie-blue);
    margin-bottom: 16px;
}

.pitie-app h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--pitie-blue);
    margin-bottom: 16px;
}

.pitie-app h4 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--pitie-blue);
}

.pitie-app .subtitle {
    font-size: 1.125rem;
    color: var(--pitie-gray-600);
    max-width: 768px;
    margin: 0 auto;
}

/* Cards */
.pitie-app .card {
    background: white;
    padding: 24px;
    border-radius: var(--pitie-radius-md);
    box-shadow: var(--pitie-shadow-lg);
    margin-top: 48px;
}

.pitie-app .card-content {
    max-width: 896px;
    margin: 0 auto;
}

/* Lists */
.pitie-app .info-list {
    list-style: disc;
    list-style-position: inside;
    color: var(--pitie-gray-700);
    font-size: 1.125rem;
}

.pitie-app .info-list li {
    margin-bottom: 8px;
}

.pitie-app .info-list .bold {
    font-weight: 700;
}

/* Forms */
.pitie-app .search-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px 16px;
}

.pitie-app .form-group {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.pitie-app .form-group-full {
    grid-column: span 2;
}

.pitie-app .form-control {
    flex: 1;
}

.pitie-app label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--pitie-gray-700);
    margin-bottom: 4px;
}

.pitie-app input[type="text"] {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--pitie-gray-300);
    border-radius: var(--pitie-radius-sm);
    font-size: 0.875rem;
    transition: border-color 0.3s ease;
}

.pitie-app input[type="text"]:focus {
    outline: none;
    border-color: var(--pitie-blue);
    box-shadow: 0 0 0 3px rgba(0, 85, 164, 0.1);
}

.pitie-app .checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pitie-app input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--pitie-blue);
}

.pitie-app .checkbox-label {
    font-size: 0.875rem;
    color: var(--pitie-gray-700);
}

/* Buttons */
.pitie-app .btn {
    padding: 10px 24px;
    border-radius: var(--pitie-radius-sm);
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.pitie-app .btn-primary {
    background-color: var(--pitie-blue);
    color: white;
}

.pitie-app .btn-primary:hover {
    background-color: var(--pitie-blue-dark);
}

.pitie-app .btn-container {
    text-align: right;
    margin-top: 24px;
}

/* Stats Grid */
.pitie-app .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 32px;
    margin-top: 48px;
}

.pitie-app .stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--pitie-radius-md);
    box-shadow: var(--pitie-shadow-lg);
    text-align: center;
}

/* Filter Section */
.pitie-app .filter-section {
    background: white;
    padding: 24px;
    border-radius: var(--pitie-radius-md);
    box-shadow: var(--pitie-shadow-lg);
    margin-top: 48px;
    margin-bottom: 32px;
}

.pitie-app .filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.pitie-app .filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pitie-app .filter-group label {
    font-weight: 600;
    color: var(--pitie-blue);
    margin-bottom: 4px;
}

.pitie-app select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--pitie-gray-300);
    border-radius: var(--pitie-radius-sm);
    font-size: 0.875rem;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.pitie-app select:focus {
    outline: none;
    border-color: var(--pitie-blue);
    box-shadow: 0 0 0 3px rgba(0, 85, 164, 0.1);
}

.pitie-app .filter-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

.pitie-app .btn-secondary {
    background-color: var(--pitie-gray-300);
    color: var(--pitie-gray-700);
}

.pitie-app .btn-secondary:hover {
    background-color: var(--pitie-gray-500);
    color: white;
}

.pitie-app .active-filters {
    margin-top: 16px;
    padding: 12px;
    background-color: var(--pitie-gray-50);
    border-radius: var(--pitie-radius-sm);
    font-size: 0.875rem;
    color: var(--pitie-gray-700);
}

.pitie-app .filter-tag {
    display: inline-block;
    background-color: var(--pitie-blue);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    margin: 4px;
    font-size: 0.75rem;
}

.pitie-app .big-stats-grid {
    display: flow;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-top: 48px;
}

.pitie-app .big-stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--pitie-radius-md);
    box-shadow: var(--pitie-shadow-lg);
    text-align: center;
}

.pitie-app .stat-label {
    color: var(--pitie-gray-600);
    margin-top: 8px;
}

.pitie-app .causes-chart {
    width: 30vw;
    height: 25vh;
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pitie-app canvas {
    padding: 0;
    margin: auto;
    height: 200px;
}

/* Table */
.pitie-app .table-container {
    overflow-x: auto;
}

.pitie-app table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.pitie-app th,
.pitie-app td {
    border: 1px solid var(--pitie-gray-300);
    padding: 12px;
    text-align: left;
}

.pitie-app th {
    background-color: var(--pitie-gray-100);
    font-weight: 600;
}

.pitie-app tr:hover {
    background-color: var(--pitie-gray-50);
}

.pitie-app .column-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    background-color: var(--pitie-gray-50);
}

.pitie-app .column-controls label {
    margin-right: 1rem;
    cursor: pointer;
    user-select: none;
}

.pitie-app .column-controls input {
    margin-right: 0.25rem;
}

/* Footer */
.pitie-app footer {
    background: white;
    border-top: 1px solid var(--pitie-gray-300);
    margin-top: 48px;
    padding: 16px 0;
}

.pitie-app .footer-content {
    text-align: center;
    color: var(--pitie-gray-500);
}

/* Utilities */
.pitie-app .text-center {
    text-align: center;
}

.pitie-app .mt-6 {
    margin-top: 24px;
}

/* Resource Links Styling */
.pitie-app .resource-link {
    color: var(--pitie-blue);
    text-decoration: underline;
    transition: color 0.3s ease;
}

.pitie-app .resource-link:hover {
    color: var(--pitie-blue-dark);
}

.pitie-app .resource-section {
    margin-bottom: 2.5rem;
}

.pitie-app .info-box {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: var(--pitie-gray-100);
    border-radius: var(--pitie-radius-md);
    border-left: 4px solid var(--pitie-blue);
}

/* Status messages (advanced stats loading state) */
.pitie-app .status-ok {
    background-color: var(--pitie-success-bg);
    color: var(--pitie-success-text);
}

.pitie-app .status-error {
    background-color: #fde8e8;
    color: var(--pitie-danger);
}

/* Responsive */
@media (max-width: 768px) {
    .pitie-app nav {
        display: none;
    }

    .pitie-app .mobile-menu-button {
        display: block;
    }

    .pitie-app h2 {
        font-size: 1.875rem;
    }

    .pitie-app h4 {
        font-size: 2rem;
    }

    .pitie-app .search-form {
        grid-template-columns: 1fr;
    }

    .pitie-app .form-group-full {
        grid-column: span 1;
    }

    .pitie-app .stats-grid {
        grid-template-columns: 1fr;
    }

    .pitie-app .btn-container {
        text-align: center;
    }
}

.pitie-app iframe {
    width: 90%;
    height: 7000px;
    border: none;
    margin: 0 auto;
    display: block;
}
