/* ============================= */
/* 1) GENERAL STYLES             */
/* ============================= */

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #F5F5F5; /* Light Gray */
    color: #333333; /* Dark Gray */
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

/* Navigation Bar */
.nav {
    background-color: #03506f;
    padding: 5px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    position: relative;
    width: 100%;
    max-width: 100vw; /* Explicitly cap at viewport width */
    margin: 0 auto; /* Center within body */
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    flex-wrap: nowrap;
    box-sizing: border-box; /* Include padding in width */
}

/* Horizontal Navigation Links */
.nav-links {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    background-color: #024c5b; /* Keeping existing nav-links color */
    padding: 3px 0;
    gap: 15px;
}

.nav-links a {
    color: #fff;
    text-decoration: none;
    font-size: 1em;
    padding: 5px 10px;
    transition: background-color 0.3s ease;
}

.nav-links a:hover {
    background-color: #007BFF; /* Bright Blue */
    border-radius: 4px;
}

.nav .cart-icon {
    width: 24px;
    height: 24px;
}

/* Logo Styling */
.nav .logo {
    font-size: 1.2em;
    font-weight: normal;
}

.logo a {
    font-size: 1em;
    color: #ffffff;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.0;
}

.nav .top-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Welcome Message */
.welcome-message {
    margin-right: auto;
    font-size: 1em;
    color: #ffffff;
    line-height: 1.5;
}

/* User Dropdown Styles (Restored and Updated) */
.user-dropdown {
    position: relative;
    display: inline-block;
    cursor: pointer;
    margin-left: 15px;
}

.user-dropdown .user-name {
    color: #fff;
    font-size: 0.9em;
}

.user-dropdown .arrow-down {
    font-size: 0.7em;
    margin-left: 5px;
}

.user-dropdown .dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: #fff;
    min-width: 150px;
    box-shadow: 0px 8px 16px rgba(0,0,0,0.2);
    z-index: 1;
}

.user-dropdown .dropdown-content a {
    color: #333333; /* Dark Gray */
    padding: 10px 15px;
    text-decoration: none;
    display: block;
    font-size: 0.9em;
}

.user-dropdown .dropdown-content a:hover {
    background-color: #F5F5F5; /* Light Gray */
    color: #007BFF; /* Bright Blue */
}

/* Show dropdown on hover */
.user-dropdown:hover .dropdown-content {
    display: block;
}

/* Container/Forms */
.container {
    margin-top: 60px;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 1200px; /* Match JSON maxWidth */
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* Ensure .placed-component respects inline styles */
.placed-component {
    box-sizing: border-box;
}

.container, .form-container {
    margin-top: 80px;
    text-align: center;
    max-width: 800px;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0px 6px 8px rgba(0, 0, 0, 0.2);
}

.canvas {
    width: 100%;
    max-width: 1200px; /* Explicitly set, not inherited */
    margin: 0 auto; /* Center within container */
    position: relative; /* Contain relative components */
}

/* Input Fields and Buttons */
input, button {
    display: block;
    width: 100%;
    margin: 10px 0;
    padding: 10px;
    border-radius: 5px;
    border: none;
    font-size: 1em;
}

input {
    background-color: #ffffff;
    color: #333333; /* Dark Gray */
    border: 1px solid #6C757D; /* Medium Gray */
}

/* General Button Styles */
button, .button {
    background-color: #007BFF; /* Bright Blue */
    color: #ffffff;
    font-size: 1em;
    font-weight: bold;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-align: center;
    display: inline-block;
    text-decoration: none;
}

button:hover, .button:hover {
    background-color: #0056B3; /* Darker Blue */
}

.button.full-width {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 10px;
}

/* Requirements */
.requirements {
    font-size: 0.9em;
    color: #6C757D; /* Medium Gray */
    text-align: left;
    margin-bottom: 10px;
}

.features li {
    font-size: 1.2em;
    margin: 10px 0;
    line-height: 1.6;
}

/* Search Form */
.search-form {
    display: flex;
    align-items: center;
}

.search-form input[type="text"] {
    padding: 5px 10px;
    border: 1px solid #6C757D; /* Medium Gray */
    border-radius: 4px;
}

.search-form button {
    background-color: #007BFF; /* Bright Blue */
    color: #fff;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    margin-left: 5px;
}

.search-form button:hover {
    background-color: #0056B3; /* Darker Blue */
}

/* Cart Icon */
.cart-link {
    position: relative;
}

.cart-icon {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

/* Error/Success Messages */
.error-message {
    color: #ff0000;
    font-size: 1em;
    margin-bottom: 15px;
    text-align: center;
    background-color: #ffe6e6;
    padding: 10px;
    border: 1px solid #ff0000;
    border-radius: 5px;
}

.success {
    color: green;
    font-weight: bold;
}

.error {
    color: red;
    font-weight: bold;
}

/* ============================= */
/* 2) CRUD-SPECIFIC STYLES       */
/* ============================= */

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    border: 1px solid #6C757D; /* Medium Gray */
    padding: 8px;
    text-align: left;
}

th {
    background-color: #F5F5F5; /* Light Gray */
}

/* Sorting links in table headers */
th a {
    color: #333333; /* Dark Gray */
    text-decoration: none;
}

th a:hover {
    text-decoration: underline;
}

/* Toolbar Container Above Table */
.toolbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    width: 100%;
}

/* Left side: search area */
.toolbar-search {
    /* Relies on .search-form styling */
}

/* Right side: icons area */
.toolbar-icons {
    display: inline-flex;
    gap: 8px;
}

/* Icon button styling */
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    padding: 0;
    margin: 0;
}

.icon-btn:hover {
    opacity: 0.7;
}

/* Action column styles for each row */
.action-links {
    white-space: nowrap;
    text-align: center;
}

.action-icon {
    text-decoration: none;
    margin: 0 5px;
    font-size: 1.2em;
    color: #333333; /* Dark Gray */
}

.action-icon:hover {
    opacity: 0.7;
}

/* Pagination container & links */
.pagination {
    margin-top: 10px;
    text-align: right;
}

.pagination a {
    padding: 5px 10px;
    text-decoration: none;
    border: 1px solid #6C757D; /* Medium Gray */
    margin: 0 2px;
    color: #333333; /* Dark Gray */
}

.pagination a.active {
    background-color: #6C757D; /* Medium Gray */
    color: #fff;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0px 0px 10px rgba(0,0,0,0.3);
    z-index: 1000;
    min-width: 400px;
}

/* Grid layout for filters */
.filter-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Filter row */
.filter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Modal buttons */
.modal-buttons {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
}

.modal-buttons button {
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    background-color: #007BFF; /* Bright Blue */
    color: #fff;
}

.modal-buttons button:hover {
    background-color: #0056B3; /* Darker Blue */
}

/* Close button style */
.close {
    float: right;
    font-size: 20px;
    cursor: pointer;
}

/* Products Grid */
.products-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

/* Individual Product Item */
.product-item {
    background: #fff;
    border: 1px solid #6C757D; /* Medium Gray */
    border-radius: 4px;
    padding: 15px;
    width: 250px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.product-item h4 {
    font-size: 1.1em;
    margin-bottom: 10px;
}

.product-item .price {
    font-size: 1em;
    color: #e74c3c;
    margin-bottom: 10px;
}

.product-thumb {
    max-width: 100%;
    height: auto;
    margin-bottom: 10px;
}

.product-item .button {
    background-color: #007BFF; /* Bright Blue */
    color: #fff;
    padding: 8px 12px;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.product-item .button:hover {
    background-color: #0056B3; /* Darker Blue */
}

/* Templates Grid */
.templates-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.template-option {
    border: 1px solid #6C757D; /* Medium Gray */
    padding: 10px;
    width: 250px;
    text-align: center;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.template-option img {
    max-width: 100%;
    height: auto;
    margin-bottom: 10px;
}

.template-option h3 {
    font-size: 1.1em;
    margin: 10px 0;
}

.template-option p {
    font-size: 0.9em;
    color: #6C757D; /* Medium Gray */
}

.template-option .button,
.template-option button {
    background-color: #007BFF; /* Bright Blue */
    color: #fff;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.3s ease;
}

.template-option .button:hover,
.template-option button:hover {
    background-color: #0056B3; /* Darker Blue */
}

.top-right a {
    color: #fff;
    text-decoration: none;
}

.top-right a:hover {
    color: #007BFF; /* Bright Blue */
}