/* static/css/style.css */

/* --- Reset and Base --- */
html {
    scroll-behavior: smooth;
    box-sizing: border-box;
    height: 100%; 
}

*, *::before, *::after {
    box-sizing: inherit;
}

body { 
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; 
    background-color: #1a1a1a; 
    color: #e0e0e0; 
    margin: 0; 
    line-height: 1.6;
    overflow-x: hidden; 
    display: flex; 
    flex-direction: column; 
    min-height: 100vh; /* Changed from 100% to 100vh for direct viewport height */
    /* padding-top will be handled by JavaScript and needs to be accounted for */
}

a {
    color: #00aaff;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* --- Header Area --- */
.header-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000; 
    background-color: #222; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: top 0.3s ease-in-out; 
}

.header-area.header-hidden {
    top: -200px; 
}


/* --- Navbar --- */
.navbar {
    border-bottom: 1px solid #3a3a3a;
    padding: 0 20px;
    height: 60px; 
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    font-size: 1.5em;
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    display: flex;
    align-items: center;
}

.navbar-brand .fa-bolt { 
    color: #f39c12;
    margin-right: 8px;
}
.navbar-brand:hover {
    text-decoration: none;
    color: #f0f0f0;
}

.navbar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-item a {
    color: #ccc;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    display: inline-flex; 
    align-items: center;
    gap: 6px; 
    font-size: 0.95em;
}

.nav-item a:hover, 
.nav-item a.active { 
    color: #fff;
    background-color: #333;
    text-decoration: none;
}

.nav-item a.button-style { 
    background-color: #007bff;
    color: white !important; 
    font-weight: 500;
}
.nav-item a.button-style:hover { 
    background-color: #0056b3; 
    color: white !important;
}

.nav-item a.premium-link .fa-star,
.nav-item a.premium-link .far.fa-star { 
    color: #f39c12; 
    margin-right: 5px;
}

/* --- User Dropdown --- */
.user-dropdown { position: relative; }

.user-dropdown-toggle { 
    cursor: pointer; 
}
.user-dropdown-toggle .fa-user-circle { margin-right: 6px; }
.user-dropdown-toggle .fa-caret-down { font-size: 0.8em; margin-left: 4px;}

.user-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 5px); 
    right: 0;
    background-color: #2c2c2c;
    border: 1px solid #444;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    min-width: 200px; 
    z-index: 1010; 
    padding: 8px 0; 
}

.user-dropdown.open .user-dropdown-menu { display: block; }

.user-dropdown-menu a {
    display: block;
    padding: 10px 18px; 
    color: #ccc;
    text-decoration: none;
    font-size: 0.95em;
    white-space: nowrap; 
}

.user-dropdown-menu a:hover { 
    background-color: #383838; 
    color: #fff; 
    text-decoration: none;
}

.user-dropdown-menu a .fas, 
.user-dropdown-menu a .fab { 
    margin-right: 10px; 
    width: 16px; 
    text-align: center;
}

.user-dropdown-menu .dropdown-divider { 
    height: 1px; 
    background-color: #444; 
    margin: 8px 0; 
}

/* --- Controls Bar --- */
.controls-bar {
    display: flex;
    justify-content: space-between; 
    align-items: center;
    flex-wrap: wrap; 
    background-color: #262626; 
    padding: 8px 20px; 
    border-bottom: 1px solid #3a3a3a;
    gap: 15px; 
}

.search-form {
    display: flex; 
    flex-grow: 1; 
    max-width: 400px; 
    min-width: 200px; 
}
.search-form form { 
    display: flex; 
    width: 100%; 
    gap: 0; 
}
.search-form input[type="search"] { 
    padding: 8px 12px; 
    border-radius: 5px 0 0 5px; 
    border: 1px solid #444; 
    border-right: none; 
    background-color: #333; 
    color: #e0e0e0; 
    flex-grow: 1; 
    font-size: 0.9rem; 
}
.search-form input[type="search"]:focus {
    outline: none;
    border-color: #007bff; 
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25); 
}
.search-form input[type="search"]::placeholder { color: #888; opacity: 0.7;}

.search-form button { 
    padding: 8px 15px; 
    border-radius: 0 5px 5px 0; 
    border: 1px solid #007bff; 
    background-color: #007bff; 
    color: white; 
    cursor: pointer; 
    font-size: 0.9rem; 
    display: flex; align-items: center; justify-content: center; 
    flex-shrink: 0; 
}
.search-form button:hover { background-color: #0056b3; border-color: #0056b3; }

.sort-options { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    flex-shrink: 0; 
}
.sort-options label { 
    font-size: 0.85em; 
    color: #aaa; 
    margin-bottom: 0; 
    white-space: nowrap; 
}
.sort-select-wrapper { position: relative; display: inline-block; }
.sort-options select { 
    appearance: none; -webkit-appearance: none; -moz-appearance: none; 
    background-color: #333; 
    border: 1px solid #444; 
    padding: 8px 28px 8px 12px; 
    border-radius: 5px; 
    color: #e0e0e0; 
    cursor: pointer; 
    font-size: 0.9rem; 
    min-width: 160px; 
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23AAAAAA%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.6-3.6%205.4-7.9%205.4-12.9%200-5-1.8-9.2-5.4-12.8z%22%2F%3E%3C%2Fsvg%3E'); 
    background-repeat: no-repeat; background-position: right 10px center; background-size: 10px 10px; 
}
.sort-options select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

/* --- Page Container & Footer --- */
main.page-container {
    padding: 20px; /* Default padding */
    max-width: 1600px;
    margin: 0 auto;
    flex: 1 0 auto; /* This is key: flex-grow: 1, flex-shrink: 0, flex-basis: auto */
    width: 100%; /* Ensure it tries to take full width within constraints */
    box-sizing: border-box; /* Include padding in width calculation */
}

.site-footer {
    background-color: #222;
    color: #aaa;
    padding: 20px 0;
    text-align: center;
    font-size: 0.9em;
    border-top: 1px solid #3a3a3a;
    width: 100%;
    flex-shrink: 0; 
}
.footer-content {
    padding: 0 20px;
}
.footer-nav a { color: #ccc; text-decoration: none; margin: 0 8px; }
.footer-nav a:hover { color: #fff; text-decoration: underline; }
.site-footer p { margin: 0 0 10px 0; color: #888; }

/* --- Flashed Messages --- */
.message-flash-container { 
    position: fixed; 
    bottom: 20px; 
    right: 20px;  
    z-index: 2000; 
    width: auto; 
    max-width: 350px; 
}

.message { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 12px 15px; 
    padding-right: 35px; 
    margin-bottom: 10px; 
    border-radius: 5px; 
    border: 1px solid transparent; 
    font-size: 0.9em; 
    text-align: left; 
    opacity: 0; 
    animation: fadeInBottomRight 0.5s forwards, fadeOutBottomRight 0.5s 4.5s forwards; 
    box-shadow: 0 3px 8px rgba(0,0,0,0.3); 
    position: relative; 
    color: #fff; 
}
.message.danger { background-color: #c0392b; border-color: #a93226; }
.message.info { background-color: #2980b9; border-color: #2471a3; }
.message.success { background-color: #27ae60; border-color: #229954; }
.message.warning { background-color: #f39c12; border-color: #d68910; color: #333; }

.message .close-flash {
    position: absolute;
    top: 5px;
    right: 7px;
    background: none;
    border: none;
    font-size: 1.5em; 
    color: rgba(255, 255, 255, 0.7); 
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}
.message.warning .close-flash { 
    color: rgba(0, 0, 0, 0.5);
}
.message .close-flash:hover {
    color: #fff;
}
.message.warning .close-flash:hover {
    color: #000;
}

@keyframes fadeInBottomRight { 
    from { opacity: 0; transform: translateX(30px) translateY(10px); } 
    to { opacity: 1; transform: translateX(0) translateY(0); } 
}
@keyframes fadeOutBottomRight { 
    from { opacity: 1; transform: translateX(0) translateY(0); } 
    99% { opacity: 0; transform: translateX(30px) translateY(10px); visibility: visible; }
    100% { opacity: 0; transform: translateX(30px) translateY(10px); visibility: hidden; }
}


/* --- Utility Classes --- */
.sr-only { 
    position:absolute; 
    width:1px; 
    height:1px; 
    padding:0; 
    margin:-1px; 
    overflow:hidden; 
    clip:rect(0,0,0,0); 
    border:0; 
}

/* --- Responsive Table Wrapper --- */
.responsive-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; 
    margin-bottom: 15px; 
}
.responsive-table-wrapper table { 
    margin-bottom: 0; 
}


/* --- START: Mobile Specific Overrides --- */
@media (max-width: 768px) {
    .navbar {
        padding: 0 10px; 
        height: 55px; 
    }
    .navbar-brand {
        font-size: 1.3em; 
    }
    .navbar-nav {
        gap: 5px;
    }
    .nav-item a {
        padding: 7px 9px;
        font-size: 0.85em;
    }
     .user-dropdown-menu {
        min-width: 170px;
    }
    .user-dropdown-menu a {
        padding: 9px 14px;
        font-size: 0.9em;
    }

    .controls-bar {
        flex-direction: column; 
        align-items: stretch; 
        padding: 10px;
        gap: 10px;
    }
    .search-form {
        max-width: 100%; 
        width: 100%;
        min-width: unset; 
    }
     .search-form input[type="search"] {
        font-size: 0.9rem;
    }
    .search-form button {
        font-size: 0.9rem;
    }
    .sort-options {
        width: 100%;
        justify-content: flex-start; 
    }
    .sort-options label {
        font-size: 0.9em;
    }
    .sort-options select {
        flex-grow: 1; 
        font-size: 0.9em;
        padding: 8px 25px 8px 10px;
        min-width: 0; 
    }

    main.page-container { 
        padding: 10px;
    }
    .site-footer {
        padding: 15px 0;
        font-size: 0.8em;
    }
    .footer-nav a {
        margin: 0 4px;
    }

    .form-container, 
    .admin-page-container .form-container, 
    .chart-container-wrapper,
    .stats-box {
        padding: 15px;
    }
    .form-group input[type="url"], 
    .form-group input[type="text"], 
    .form-group input[type="textarea"], 
    .form-group input[type="file"],
    .form-group input[type="date"],
    .form-group input[type="password"],
    .form-group input[type="email"] {
        padding: 10px;
        font-size: 0.95rem;
    }
    input[type="submit"].action-button,
    input[type="submit"].add-button {
        font-size: 0.95rem;
        padding: 10px 15px;
    }

    .responsive-table-wrapper { 
        border: 1px solid #3a3a3a; 
        border-radius: 4px;
    }
    .link-table th, .link-table td,
    .referral-table th, .referral-table td {
        padding: 6px 8px; 
        font-size: 0.85em; 
        white-space: normal; 
    }
     .link-table .url-cell, .link-table .title-cell { 
        max-width: none; 
        min-width: 80px; 
    }
    .action-cell {
        width: auto; 
        min-width: 70px; 
        white-space: nowrap; 
    }
    .action-button, input[type="submit"].delete-button {
        padding: 5px 8px;
        font-size: 0.8em;
    }
    .link-table img {
        max-width: 50px;
        max-height: 35px;
    }
    .admin-actions-bar {
        padding: 10px;
        gap: 10px;
    }
    .admin-actions-bar a.action-link {
        padding: 8px 12px;
        font-size: 0.9em;
    }
    .message-flash-container {
        bottom: 10px;
        right: 10px;
        left: 10px; 
        max-width: none; 
        width: auto; 
    }
    .message {
        font-size: 0.85rem;
        max-width: 100%; 
    }
}

@media (max-width: 480px) {
    .navbar-brand {
        font-size: 1.2em;
    }
    .nav-item a {
        padding: 5px 6px;
        font-size: 0.75em; 
    }
    .nav-item a .fas, .nav-item a .far, .nav-item a .fab {
        margin-right: 3px; 
    }
    .user-dropdown-toggle .fa-user-circle {
        margin-right: 3px;
    }
    .sort-options label {
        display: none; 
    }
    .sort-options select {
         min-width: 100px;
         padding: 7px 20px 7px 8px;
         font-size: 0.85em;
    }
    .footer-nav a {
        margin: 0 3px;
    }
    .stats-box p, .stats-box strong, .stats-box .stat-value {
        font-size: 0.85em;
    }
    .stats-box .stat-value {
        font-size: 1em;
    }
    main.page-container h1, .admin-dashboard-container h1 { font-size: 1.4em; } 
    main.page-container h2, .admin-dashboard-container h2 { font-size: 1.2em; } 

    .gallery-item .card-footer .button.btn-open,
    .gallery-item .card-footer .like-button {
        padding: 6px 8px;
        font-size: 0.8em;
    }
    .gallery-item .card-footer .like-button {
        font-size: 1em; 
    }
    .gallery-item .card-footer .likes-count {
        font-size: 0.7em;
    }
    .pagination a, .pagination span { 
        padding: 4px 7px; 
        font-size: 0.75em; 
    }
}
/* --- END: Mobile Specific Overrides --- */