/* app.css */

/* CSS Definitions: The heart of our outstanding design! */
:root {
    /* Color Palette */
    --primary-color: #4CAF50; /* Green - for success, main calls to action, borders */
    --primary-hover: #45a049;
    --secondary-color: #007bff; /* Blue - for general buttons, links */
    --secondary-hover: #0056b3;
    --danger-color: #dc3545; /* Red - for delete/logout */
    --danger-hover: #c82333;
    --info-color: #ffc107; /* Orange - for info messages */
    --info-hover: #e0a800;
    --dark-blue: #2c3e50; /* Deep Blue - for headers, main headings */

    /* Neutral Colors */
    --text-color: #333; /* Dark grey for main text */
    --light-text-color: #555; /* Lighter grey for secondary text */
    --accent-text-color: #1a73e8; /* Vibrant blue for active links */
    --light-bg: #f0f2f5; /* Very light grey for page background */
    --white-bg: #ffffff; /* Pure white for cards/containers */
    --border-color: #e0e0e0; /* Light grey for borders */
    --shadow-color: rgba(0, 0, 0, 0.08); /* Subtle shadow color */
}

/* Base Body Styles - Apply these to the whole page */
body {
    font-family: 'Poppins', sans-serif; /* Our chosen professional font */
    background-color: var(--light-bg); /* Soft background color */
    margin: 0; /* Remove default browser margin */
    padding-top: 0; /* Default no top padding, JS will add if header is visible */
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
    color: var(--text-color); /* Default text color */
    line-height: 1.6; /* Comfortable line spacing */
    min-height: 100vh; /* Ensure body takes full viewport height */
    box-sizing: border-box; /* Include padding in element's total width and height */
    
    /* These styles help center login/register forms */
    display: flex; 
    flex-direction: column; /* Stack header and container */
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
    text-align: center; /* Default for content within containers */
}

/* Class added by JS when header is visible */
body.has-fixed-header {
    padding-top: 80px; /* Space for the fixed header */
    justify-content: flex-start; /* Align content from top when header is present */
}

/* Global Header Navigation Bar - Matches the dashboard screenshot */
.header-nav-bar {
    background-color: var(--dark-blue); /* Deep blue background */
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between; /* Space out branding and user info */
    align-items: center; /* Vertically align items */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); /* Soft shadow for depth */
    position: fixed; /* Makes the header stick to the top */
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000; /* Ensures it's always on top */
    box-sizing: border-box;
}

.nav-brand {
    font-size: 1.5em; /* Larger font for brand name */
    font-weight: 700; /* Bold */
    letter-spacing: 1px; /* Slight letter spacing */
}

.nav-user-info {
    display: flex;
    align-items: center;
    gap: 15px; /* Space between avatar, name, and logout button */
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%; /* Perfect circle */
    object-fit: cover; /* Ensures image fills the circle without distortion */
    border: 2px solid white; /* White border around avatar */
}

.user-full-name {
    font-size: 1em;
    font-weight: 500;
}

.logout-btn {
    background-color: var(--danger-color); /* Red logout button */
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    text-decoration: none; /* No underline */
    font-weight: 600;
    transition: background-color 0.3s ease; /* Smooth hover effect */
}

.logout-btn:hover {
    background-color: var(--danger-hover);
}

/* Main Application Container - Holds all views */
#appContainer {
    width: 100%;
    display: flex; /* Flexbox for centering auth forms or holding dashboard */
    justify-content: center;
    align-items: center;
    flex-grow: 1; /* Allows container to take available vertical space */
    padding: 0 20px; /* Padding for small screens */
    box-sizing: border-box;
}


/* Main Content Area - Wrapper for cards on dashboard/profile */
.main-content-area {
    max-width: 900px; /* Limits the overall content width */
    margin: 30px auto 20px auto; /* Centers the content area with top/bottom margin */
    display: flex; /* Default to flex for dashboard layout */
    flex-wrap: wrap; /* Allows cards to wrap to the next line on smaller screens */
    gap: 25px; /* Space between individual cards */
    justify-content: center; /* Centers cards horizontally if there's extra space */
    align-items: flex-start; /* Aligns cards to the top of the container */
    width: 100%; /* Take full width of parent (appContainer) */
}

/* Card Styling - Reusable component for sections */
.card {
    background-color: var(--white-bg); /* White background */
    padding: 30px;
    border-radius: 12px; /* Rounded corners */
    box-shadow: 0 5px 15px var(--shadow-color); /* Subtle shadow for depth */
    border: 1px solid var(--border-color); /* Light border */
    flex: 1; /* Allows cards to grow and shrink */
    min-width: 300px; /* Minimum width before wrapping */
    max-width: calc(50% - 12.5px); /* Max width for two cards per row (accounting for gap) */
    text-align: left; /* Ensures text inside card aligns left */
}

.card-header {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color); /* Green border accent below header */
}

/* Profile Info Items (Dashboard Card) */
.profile-info-item {
    margin-bottom: 10px;
    font-size: 1.05em;
    color: var(--light-text-color);
}
.profile-info-item strong {
    color: var(--text-color); /* Emphasize important text */
}
.profile-info-item span.role-badge {
    background-color: var(--primary-color); /* Green badge for roles */
    color: white;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: 500;
    margin-left: 10px;
}

/* Quick Links (Dashboard Card) */
.quick-links ul {
    list-style: none; /* Remove bullet points */
    padding: 0;
    margin: 0;
}
.quick-links ul li {
    margin-bottom: 10px;
    font-size: 1.05em;
    color: var(--light-text-color);
}
.quick-links ul li a { /* Style for links within quick links */
    color: var(--accent-text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}
.quick-links ul li a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}
.quick-links ul li strong {
     color: var(--primary-color); /* Highlight text within quick links */
     font-weight: 500;
}

/* Edit Profile Button (Dashboard Card) */
.btn-edit-profile {
    display: inline-block; /* Allows padding and margin */
    background-color: var(--secondary-color); /* Blue button */
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    margin-top: 20px;
    transition: background-color 0.3s ease;
}
.btn-edit-profile:hover {
    background-color: var(--secondary-hover);
}

/* Login/Register/Welcome Container - The main central form/welcome box */
.auth-container { /* Used for login, register, and add document forms */
    background-color: var(--white-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 25px var(--shadow-color); /* More pronounced shadow for main containers */
    width: 100%;
    max-width: 450px; /* Standard width for form containers */
    border: 1px solid var(--border-color);
    margin: 0 auto;
    box-sizing: border-box;
}

/* Headings */
h1 {
    color: var(--dark-blue);
    margin-bottom: 25px;
    font-weight: 700;
    font-size: 2.5em;
    text-align: center; /* Ensure headings are centered within their container */
}
h2 {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 25px;
    font-weight: 600;
}

/* Form Group & Input Styling */
.form-group {
    margin-bottom: 20px;
    text-align: left; /* Align labels/inputs left within form */
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--light-text-color);
    font-weight: 400;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: calc(100% - 24px); /* Full width minus padding */
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box; /* Include padding in width */
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--secondary-color); /* Blue border on focus */
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2); /* Soft blue shadow on focus */
    outline: none; /* Remove default browser outline */
}
.form-group small {
    display: block;
    margin-top: 5px;
    color: #777;
    font-size: 0.9em;
}

/* General Button Styling */
.btn {
    width: 100%; /* Default to full width within containers */
    padding: 12px;
    background-color: var(--secondary-color); /* Default button color */
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); /* Subtle button shadow */
    font-weight: 600;
    text-decoration: none; /* For link buttons */
    display: inline-block; /* Allows width/padding for link buttons */
    text-align: center;
}
.btn:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-2px); /* Slight lift effect */
    box-shadow: 0 6px 15px rgba(0,0,0,0.2); /* Enhanced shadow on hover */
}
/* Specific Button Colors */
.btn-primary { background-color: var(--primary-color); }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: var(--secondary-color); }
.btn-secondary:hover { background-color: var(--secondary-hover); }
.btn-danger { background-color: var(--danger-color); }
.btn-danger:hover { background-color: var(--danger-hover); }
.btn-info { background-color: var(--info-color); color: var(--text-color); } /* Info button with darker text */
.btn-info:hover { background-color: var(--info-hover); }


/* Message Box Styling (Success, Error, Info) */
.message {
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    border: 1px solid transparent; /* Default border */
}
.error { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.success { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.info { background-color: #fff3cd; color: #664d03; border-color: #ffecb5; }

/* Link Styles (for "Need an account?", "Forgot password?") */
.auth-links { /* Used for login and register links */
    text-align: center;
    margin-top: 20px;
    font-size: 0.95em;
    color: var(--light-text-color);
}
.auth-links a {
    color: var(--accent-text-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
    margin: 0 5px; /* Small space between multiple links */
}
.auth-links a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Profile Image Section (for simulated profile page) */
.profile-image-section {
    text-align: center;
    margin-bottom: 30px;
}
.profile-image-section img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}

/* Document Table Styling (New for CRUD) */
.document-table {
    width: 100%;
    border-collapse: collapse; /* Remove space between cells */
    margin-top: 20px;
    font-size: 0.95em;
}

.document-table th,
.document-table td {
    border: 1px solid var(--border-color);
    padding: 12px 15px;
    text-align: left;
}

.document-table th {
    background-color: var(--light-bg);
    color: var(--text-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9em;
}

.document-table tr:nth-child(even) {
    background-color: #f9f9f9; /* Subtle zebra striping */
}

.document-table tr:hover {
    background-color: #f1f1f1; /* Highlight row on hover */
}

.document-table td .btn {
    padding: 6px 12px;
    font-size: 0.85em;
    width: auto;
    margin: 0 5px;
    box-shadow: none; /* No extra shadow on small table buttons */
    transform: none; /* No lift effect on table buttons */
}
.document-table td .btn:hover {
    transform: none; /* No lift effect on table buttons */
    box-shadow: none;
}


/* Media Queries for Responsiveness */
@media (max-width: 768px) {
    /* Header Responsive */
    .header-nav-bar {
        padding: 10px 15px;
        flex-direction: column; /* Stack items vertically */
        gap: 10px;
    }
    .nav-user-info {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    body.has-fixed-header {
        padding-top: 120px; /* Adjust for taller header on small screens */
    }
    #appContainer {
        padding: 0 10px; /* Less padding on small screens */
    }

    /* General containers/cards */
    .auth-container,
    .card {
        padding: 30px 20px;
        max-width: 100%; /* Full width */
    }

    /* Dashboard layout */
    .main-content-area {
        flex-direction: column; /* Stack cards vertically */
        gap: 20px;
        margin: 20px auto; /* Adjust margin for smaller screens */
    }
    .card {
        max-width: 100%; /* Full width for stacked cards */
    }

    /* Button groups */
    .button-group {
        flex-direction: column; /* Stack buttons vertically */
        gap: 15px;
    }
    .button-group .btn {
        width: 100%; /* Full width when stacked */
        min-width: unset; /* Remove min-width constraint */
    }

    h1 {
        font-size: 2em;
    }
    h2, .card-header {
        font-size: 1.5em; /* Slightly smaller */
    }
    p {
        font-size: 1em;
    }
    
    /* Document Table Responsiveness */
    .document-table,
    .document-table thead,
    .document-table tbody,
    .document-table th,
    .document-table td,
    .document-table tr { 
        display: block; /* Make table elements act like blocks */
    }
    .document-table thead tr {
        position: absolute; /* Hide table headers visually but keep for screen readers */
        top: -9999px;
        left: -9999px;
    }
    .document-table tr { 
        border: 1px solid var(--border-color);
        margin-bottom: 15px;
        border-radius: 8px;
        overflow: hidden; /* For rounded corners */
    }
    .document-table td {
        border: none; /* Remove individual cell borders */
        border-bottom: 1px solid #eee; /* Add separator for readability */
        position: relative;
        padding-left: 50%; /* Space for the pseudo-element label */
        text-align: right;
    }
    .document-table td:last-child {
        border-bottom: none; /* No border for the last cell in a row */
    }
    .document-table td:before {
        content: attr(data-label); /* Use data-label attribute as a label */
        position: absolute;
        left: 0;
        width: 45%;
        padding-left: 15px;
        font-weight: 600;
        text-align: left;
        color: var(--text-color);
    }
    .document-table td .btn {
        width: calc(50% - 10px); /* Adjust button width in responsive table */
        margin-left: 5px;
        margin-right: 5px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }
    h2, .card-header {
        font-size: 1.3em;
    }
    .document-table td .btn {
        width: 100%; /* Full width buttons in very small screens */
        margin-top: 5px;
        margin-bottom: 5px;
    }
}