/* styles.css - Custom styles for My Template Trove with updated color palette, mobile optimizations, sticky footer, and hero section background */

/* Root variables for consistency */
:root {
    --primary: #003b73; /* Navy Blue */
    --secondary: #bfd7ed; /* Baby Blue */
    --accent: #60a3d9; /* Blue Grotto */
    --background: #f8f8f8; /* Gray */
    --success: #10B981; /* Green-500 */
    --error: #EF4444; /* Red-500 */
    --border-radius: 0.5rem;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease-in-out;
}

/* Global styles */
* {
    box-sizing: border-box;
}

html {
    min-height: 100vh; /* Ensure full viewport height */
    display: flex;
    flex-direction: column;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--primary);
    background-color: var(--background);
    animation: fadeIn 0.3s ease-in;
    margin: 0;
    min-height: 100vh; /* Ensure body spans viewport */
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow body to grow */
}

main {
    flex-grow: 1; /* Main content grows to push footer down */
    display: flex;
    flex-direction: column;
}

/* Fade-in animation for page load */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Header */
header {
    background: linear-gradient(180deg, var(--primary) 0%, #004d99 100%);
    padding: 1rem 0;
    position: relative;
}

header .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Logo */
.logo-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

.header-logo {
    max-height: 200px;
    width: auto;
    max-width: 100%;
}

/* Navigation Container */
.nav-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Navigation */
header nav ul {
    display: flex;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

header nav ul li a {
    position: relative;
    padding: 0.5rem 1rem;
    color: white;
    text-decoration: none;
    transition: var(--transition);
    border-radius: var(--border-radius);
    font-size: 1rem;
}

header nav ul li a:hover {
    color: white;
    background-color: var(--accent);
    transform: scale(1.05);
}

/* Hamburger Menu */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: text-shadow 0.3s ease-in-out;
}

.nav-toggle:hover {
    box-shadow: none; /* Explicitly remove shadow on hover */
    text-shadow: 0 0 6px rgba(96, 163, 217, 0.8); /* Subtle glow on icon */
}

@media (max-width: 640px) {
    .nav-toggle {
        display: block;
    }

    header nav ul {
        display: none;
        flex-direction: column;
        width: 100%;
        background: var(--primary);
        position: absolute;
        top: 100%;
        left: 0;
        padding: 1rem 0;
        z-index: 1000;
    }

    header nav ul.active {
        display: flex;
    }

    header nav ul li {
        width: 100%;
        text-align: center;
    }

    header nav ul li a {
        display: block;
        padding: 0.75rem 1rem;
        font-size: 1.1rem;
        margin: 0.25rem 0;
        border-radius: 0;
    }

    header nav ul li a:hover {
        background-color: var(--accent);
        transform: none;
    }

    .header-logo {
        max-height: 120px;
        max-width: 100%;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    inset: auto 20px 20px auto;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
    transition: background-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    margin: 0;
    box-sizing: border-box;
}

.back-to-top:hover {
    background-color: var(--accent);
    box-shadow: var(--shadow);
}

@media (max-width: 640px) {
    .back-to-top {
        width: 80%;
        left: calc(10% + env(safe-area-inset-left));
        right: calc(10% + env(safe-area-inset-right));
        bottom: calc(15px + env(safe-area-inset-bottom));
        padding: 0.5rem;
        font-size: 1.25rem;
        display: flex;
        justify-content: center;
        align-items: center;
    }
}

/* Footer */
footer {
    background: linear-gradient(180deg, #004d99 0%, var(--primary) 100%);
    color: white;
    padding: 3rem 1rem;
    text-align: center;
    width: 100%;
    flex-shrink: 0; /* Prevent footer from shrinking */
}

footer .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

footer .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    width: 100%;
    justify-content: center;
    align-items: start;
    margin: 0 auto;
}

footer .grid > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
}

footer h3 {
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

footer p, footer a {
    color: var(--primary);
    font-size: 1rem;
    line-height: 1.5;
}

footer a:hover {
    color: var(--accent);
    text-decoration: underline;
}

footer ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

footer ul li {
    margin-bottom: 0.5rem;
}

footer .mt-8 {
    margin-top: 2rem;
}

@media (max-width: 640px) {
    footer {
        padding: 2rem 0.5rem;
    }

    footer .container {
        padding: 0 0.5rem;
    }

    footer .grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        justify-items: center;
    }

    footer h3 {
        font-size: 1.1rem;
    }

    footer p, footer a {
        font-size: 0.9rem;
    }
}

/* Headings */
h1, h2, h3 {
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 1rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }

@media (max-width: 640px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
}

/* Buttons */
button, a[class*="bg-"] {
    transition: var(--transition);
    border-radius: var(--border-radius);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    display: inline-block;
    text-align: center;
}

button:hover, a[class*="bg-"]:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.bg-indigo-600 { background-color: var(--primary); }
.bg-red-600 { background-color: var(--error); }
.bg-gray-500 { background-color: #6B7280; }
.bg-blue-500 { background-color: var(--accent); }

@media (max-width: 640px) {
    button, a[class*="bg-"] {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.9rem;
    }
}

/* Forms */
input, select, textarea {
    border: 1px solid var(--primary);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    transition: var(--transition);
    width: 100%;
    box-sizing: border-box;
    font-size: 1rem;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(96, 163, 217, 0.2);
}

label {
    font-weight: 600;
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: block;
}

@media (max-width: 640px) {
    input, select, textarea {
        padding: 0.65rem;
        font-size: 0.9rem;
    }

    label {
        font-size: 0.9rem;
    }

    form {
        padding: 1rem;
    }
}

/* Library Filter Form */
.filter-form {
    width: 100%;
    margin: 0;
}

.filter-form .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    width: 100%;
    align-items: flex-end;
}

.filter-form .filter-row > div {
    flex: 1 1 0;
    padding: 0;
}

/* Ensure inputs and selects stretch fully */
.filter-form input,
.filter-form select {
    height: 2.5rem;
    width: 100%;
    margin: 0;
}

/* Button Group */
.filter-form .button-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 1 1 0;
}

.filter-form .button-group button,
.filter-form .button-group a {
    padding: 0.5rem 1rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

@media (max-width: 768px) {
    .filter-form .filter-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .filter-form .filter-row > div {
        flex: 1 1 100%;
        width: 100%;
    }

    .filter-form input,
    .filter-form select {
        width: 100%;
    }

    .filter-form .button-group {
        width: 100%;
        justify-content: space-between;
    }

    .filter-form .button-group button,
    .filter-form .button-group a {
        flex: 1;
        padding: 0.5rem;
    }
}

/* Tables */
table {
    background-color: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    width: 100%;
    border-collapse: collapse;
}

th {
    background-color: var(--accent);
    font-weight: 600;
    color: white;
    padding: 0.75rem;
    font-size: 1rem;
}

td {
    padding: 0.75rem;
    font-size: 0.95rem;
}

tr:nth-child(even) {
    background-color: var(--secondary);
}

tr:hover {
    background-color: var(--accent);
}

@media (max-width: 640px) {
    .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    th, td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .hide-on-mobile {
        display: none;
    }
}

/* Cards (Library page) */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.grid > div {
    background-color: white;
    border-radius: var(--border-radius);
    transition: var(--transition);
    padding: 1.5rem;
}

.grid > div:hover {
    transform: translateY(-0px);
    box-shadow: var(--shadow);
}

.grid img {
    border-radius: var(--border-radius);
    width: 100%;
    height: 150px;
    object-fit: cover;
}

@media (max-width: 640px) {
    .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .grid > div {
        padding: 1rem;
    }

    .grid img {
        height: 120px;
    }
}

/* Success and Error Messages */
.text-green-500 {
    color: var(--success);
    font-weight: 500;
    font-size: 1rem;
}

.text-red-500 {
    color: var(--error);
    font-weight: 500;
    font-size: 1rem;
}

@media (max-width: 640px) {
    .text-green-500, .text-red-500 {
        font-size: 0.9rem;
    }
}

/* Sections */
section {
    padding: 3rem 1rem;
}

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

/* Hero Section */
.hero-section {
    /* 
     * Ensure 'hero-productivity.jpg' exists in the 'images/' directory relative to this CSS file.
     * If the image is in a different location, update the path below.
     * Test the image URL directly in your browser: https://www.mytemplatetrove.com/images/hero-productivity.jpg
     * Alternative absolute path (uncomment to test):
     * background-image: url('https://www.mytemplatetrove.com/images/hero-productivity.jpg');
     */
    background-image: url('images/hero-productivity.jpg');
    background-size: cover;
    background-position: center;
    background-color: #f0f0f0; /* Fallback color if image fails to load */
    position: relative;
    padding: 5rem 1rem;
}

.hero-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: rgba(0, 59, 115, 0.5); /* Semi-transparent navy blue overlay using --primary */
}

.hero-section .container {
    position: relative;
    z-index: 10;
    text-align: center;
}

.hero-section h1 {
    color: white; /* White for contrast against overlay */
    font-size: 3rem; /* Slightly larger for impact */
    margin-bottom: 1.5rem;
}

.hero-section p {
    color: #e6eef7; /* Light grayish-blue for readability, close to --secondary */
    font-size: 1.25rem;
    margin-bottom: 2rem;
}

.hero-section .flex {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

@media (max-width: 640px) {
    .hero-section {
        padding: 3rem 0.5rem;
    }

    .hero-section h1 {
        font-size: 2rem;
    }

    .hero-section p {
        font-size: 1rem;
    }

    .hero-section .flex {
        flex-direction: column;
        gap: 0.75rem;
    }

    .hero-section .flex a {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 640px) {
    section {
        padding: 2rem 0.5rem;
    }

    .container {
        padding: 0 0.5rem;
    }
}

/* Utility classes */
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Additional mobile optimizations */
@media (max-width: 640px) {
    h1, h2, h3, p {
        text-align: center;
    }
}

/* Chart Cards */
.chart-card {
    background-color: var(--background) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--shadow) !important;
    padding: 2rem !important;
    min-height: 500px !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    transition: all 0.3s ease-in-out !important;
}

.chart-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15) !important;
}

.chart-card canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: 400px !important;
}

/* Override grid constraints */
.grid .chart-card {
    grid-column: 1 / -1 !important; /* Span full grid width */
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .chart-card {
        min-height: 450px !important;
        padding: 1.5rem !important;
    }
    .chart-card canvas {
        height: 350px !important;
    }
}

@media (max-width: 640px) {
    .chart-card {
        min-height: 400px !important;
        padding: 1rem !important;
    }
    .chart-card canvas {
        height: 300px !important;
    }
}

/* Upload Template Card */
.upload-template-card {
    background-color: var(--background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 2rem !important;
    margin-bottom: 1.5rem;
}

/* Upload Template Form */
.upload-template-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}

.upload-template-form .form-group {
    margin-bottom: 1.5rem;
}

.upload-template-form label {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
    display: block;
}

.upload-template-form input,
.upload-template-form select,
.upload-template-form textarea {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0.75rem !important;
    border: 1px solid var(--primary) !important;
    border-radius: var(--border-radius) !important;
    font-size: 1rem;
    margin: 0 !important;
    box-sizing: border-box;
}

.upload-template-form input:focus,
.upload-template-form select:focus,
.upload-template-form textarea:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(96, 163, 217, 0.2) !important;
}

.upload-template-form button {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    background-color: var(--primary);
    color: white;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.upload-template-form button:hover {
    background-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .upload-template-card {
        padding: 1.5rem !important;
    }
    .upload-template-form .form-group {
        margin-bottom: 1rem;
    }
    .upload-template-form input,
    .upload-template-form select,
    .upload-template-form textarea {
        padding: 0.65rem !important;
        font-size: 0.9rem;
    }
    .upload-template-form button {
        padding: 0.65rem;
        font-size: 0.9rem;
    }
}