/* Color Palette: 
   --primary-blue: #003366 (Deep Navy/Ocean)
   --secondary-gold: #FFC300 (Accent/Luxury)
   --background-light: #F4F7F9 (Clean background)
   --text-dark: #333333 
*/

:root {
    --primary-blue: #003366;
    --secondary-gold: #FFC300;
    --background-light: #F4F7F9;
    --text-dark: #333333;
    --button-bg: #FFFFFF;
    --button-shadow: rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: sans-serif;
}

body {
    background-color: var(--background-light);
    color: var(--text-dark);
}

/* -------------------- HEADER (Top Section) -------------------- */
header {
    background-color: var(--primary-blue);
    color: white;
    padding: 15px 30px;
    box-shadow: 0 4px 6px var(--button-shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.5em;
    font-weight: 300;
    letter-spacing: 1px;
}

.top-nav {
    display: flex; 
    align-items: center;
}

.top-nav a {
    color: white;
    text-decoration: none;
    margin-left: 25px;
    font-size: 0.9em;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.top-nav a:hover {
    opacity: 1;
    color: var(--secondary-gold);
}

/* -------------------- MAIN LAYOUT (Left Pane + Main Pane) -------------------- */
.container {
    display: flex; 
    max-width: 1200px;
    margin: 20px auto;
    gap: 20px;
}

/* Left Pane: Sidebar Navigation */
.sidebar {
    flex: 0 0 220px; 
    background-color: var(--button-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px var(--button-shadow);
    height: fit-content;
}

.sidebar h2 {
    color: var(--primary-blue);
    font-size: 1em;
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.side-nav a {
    display: block;
    padding: 10px 15px;
    margin-bottom: 5px;
    text-decoration: none;
    color: var(--text-dark);
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.side-nav a i {
    margin-right: 10px;
    width: 15px;
}

.side-nav a:hover {
    background-color: var(--background-light);
    color: var(--primary-blue);
}

/* Main Pane */
.main-content {
    flex-grow: 1;
}

/* Hero Card (Used on index.php and modules) */
.hero-card {
    background: var(--primary-blue);
    color: white;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 4px 8px var(--button-shadow);
}

.hero-card h2 {
    font-size: 1.8em;
    margin-bottom: 5px;
}

.hero-card p {
    opacity: 0.9;
}

/* -------------------- DASHBOARD ACTION GRID (Buttons) -------------------- */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.action-grid h2 {
    grid-column: 1 / -1;
    font-size: 1.2em;
    margin-bottom: 10px;
    color: var(--primary-blue);
    border-bottom: 2px solid var(--secondary-gold);
    padding-bottom: 5px;
}

.action-button {
    display: block;
    background-color: var(--button-bg);
    padding: 25px;
    text-align: center;
    text-decoration: none;
    color: var(--text-dark);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--button-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.action-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px var(--button-shadow);
    border: 1px solid var(--primary-blue);
}

.action-button i {
    font-size: 3em;
    margin-bottom: 10px;
    color: var(--primary-blue);
}

.action-button h3 {
    font-size: 1.2em;
    margin-bottom: 5px;
}

.action-button p {
    font-size: 0.85em;
    color: #666;
}

/* Gold Accent for AI/Admin Buttons */
.ai-insights i, .admin i {
    color: var(--secondary-gold);
}

/* -------------------- PRODUCT LISTING STYLES -------------------- */

.page-header {
    margin-bottom: 20px;
}

.page-header h2 {
    color: var(--primary-blue);
    border-bottom: 2px solid var(--background-light);
    padding-bottom: 5px;
    margin-bottom: 5px;
}

/* --- PRODUCT CARD GRID --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* REMOVED: .product-card-link styles */

.product-card {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    position: relative; 
    transition: box-shadow 0.2s, border-left 0.2s;
    height: 100%; 
}

.product-card:hover {
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
    /* Restore hover effect for visibility */
    border-left: 5px solid var(--primary-blue); 
}

.card-icon {
    font-size: 2.5em;
    color: var(--primary-blue);
    margin-bottom: 10px;
    align-self: flex-start;
}

.product-card h4 {
    font-size: 1.1em;
    margin-bottom: 5px;
    color: var(--text-dark);
}

.product-card .model {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 10px;
}

.card-meta {
    font-size: 0.8em;
    color: #888;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-top: 10px;
    border-top: 1px dashed #eee;
    flex-grow: 1; /* Pushes action section to the bottom */
}

.card-meta i {
    margin-right: 5px;
    color: var(--primary-blue);
}

/* NEW: Action wrapper for buttons at the bottom of the card */
.product-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

/* NEW: Style for the Edit/Details button */
.edit-details-btn {
    padding: 8px 12px;
    background-color: var(--primary-blue);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.edit-details-btn:hover {
    background-color: #004488;
}

.edit-details-btn i {
    margin-left: 5px;
}

/* NEW: Style for the View Document button */
.view-document-btn {
    padding: 8px 12px;
    background-color: #6c757d; /* Gray for document action */
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background-color 0.2s;
    margin-left: 10px;
}

.view-document-btn:hover {
    background-color: #5a6268;
}

.view-document-btn i {
    margin-left: 5px;
}


/* -------------------- FILTER CONTROLS -------------------- */
.filter-controls {
    display: flex;
    gap: 15px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    flex-wrap: wrap; 
}

.filter-group {
    display: flex;
    flex-direction: column;
    flex-grow: 1; 
    min-width: 150px; 
}

.filter-group label {
    font-size: 0.8em;
    color: var(--text-dark);
    margin-bottom: 5px;
    font-weight: bold;
}

.filter-controls select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
    background-color: var(--background-light);
    width: 100%;
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-grow: 1; 
}

/* NEW: Compact button for 'Add Product' in the filter bar */
.compact-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px; 
    background-color: #38a169; /* Green */
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 1.1em;
    align-self: flex-end;
    transition: background-color 0.2s;
}

.compact-add-btn:hover {
    background-color: #2c774d;
}

.clear-filters-btn {
    padding: 8px 15px;
    background-color: #f0f0f0;
    color: var(--text-dark);
    text-decoration: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    transition: background-color 0.2s;
    height: 35px; 
    line-height: 1.2; 
    align-self: flex-end;
}

.clear-filters-btn:hover {
    background-color: #e0e0e0;
}

/* Checkbox filter group styling (for 'Show Low Stock Only' on spares.php) */
.filter-group.checkbox-group {
    flex-direction: row;
    align-items: center;
    padding-top: 25px; 
    min-width: 180px;
}

.filter-group.checkbox-group input {
    width: 18px;
    height: 18px;
    margin-right: 8px;
}

/* NEW: Compact button for 'Add Stock' inside the product card */
.compact-card-add-btn {
    /* Positioned inside product-card-actions now */
    display: flex; 
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: var(--secondary-gold);
    color: var(--text-dark);
    text-decoration: none;
    border-radius: 50%; /* Circular button */
    font-size: 0.8em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    z-index: 10;
    transition: background-color 0.2s, transform 0.2s;
}

.compact-card-add-btn:hover {
    background-color: #ffb300;
    transform: scale(1.1);
}

/* Ensure buttons take up the minimum space needed within the action wrapper */
.product-card-actions > a {
    flex-shrink: 0;
}


/* --- LOAD MORE BUTTON --- */
.load-more-container {
    text-align: center;
    margin: 30px 0 20px 0;
}

.load-more-btn {
    display: inline-block;
    padding: 10px 25px;
    background-color: var(--secondary-gold);
    color: var(--text-dark);
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: opacity 0.2s;
}

.load-more-btn:hover {
    opacity: 0.9;
}

/* -------------------- DATA TABLE STYLES (For stocks.php and spares.php) -------------------- */

.stock-table-container {
    overflow-x: auto; 
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--button-shadow);
    margin-top: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    min-width: 700px; 
}

.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background-color: var(--background-light);
    color: var(--primary-blue);
    font-weight: bold;
    text-transform: uppercase;
}

.data-table th a {
    color: var(--primary-blue);
    text-decoration: none;
    display: inline-block;
}

.data-table tbody tr:hover {
    background-color: #f7f7f7;
}

/* Stock Status Highlighting */
.status-broken {
    background-color: #ffe0e0; 
}

.status-low-stock {
    background-color: #fef3c7; 
    border-left: 5px solid #d97706; 
}

.status-ok {
    color: #38a169;
}

.status-fail {
    color: #e53e3e;
}

/* Condition Badges (Used on spares.php) */
.condition-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: bold;
    color: white; 
    text-transform: capitalize;
    background-color: #6c757d; /* Neutral Gray Fallback */
    display: inline-block; 
    min-width: 60px; 
    text-align: center; 
}

/* Specific Condition Colors */
.condition-new { background-color: #28a745; }
.condition-excellent-new { background-color: #28a745; } 
.condition-good { background-color: #007bff; } 
.condition-fair { background-color: #fd7e14; }
.condition-poor { background-color: #dc3545; }
.condition-broken-not-working { background-color: #c53030; } 
.condition-sealed { background-color: #6610f2; }
.condition-used-good { background-color: #ffc107; color: #343a40; }


.sku-text {
    font-size: 0.8em;
    color: #888;
}

/* -------------------- FOOTER -------------------- */
footer {
    background-color: var(--text-dark);
    color: white;
    text-align: center;
    padding: 10px 0;
    margin-top: 30px;
    font-size: 0.8em;
}

/* -------------------- PRODUCT DETAILS / EDIT FORM STYLES (New) -------------------- */
.details-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.details-actions {
    display: flex;
    gap: 10px;
}

.details-form-container {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--primary-blue);
    font-size: 0.9em;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
}

.form-group input[readonly] {
    background-color: #f0f0f0;
    color: #666;
    border-style: dashed;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 15px;
}

.primary-btn {
    background-color: var(--primary-blue) !important;
    color: white !important;
    border: none !important;
    cursor: pointer;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
}

/* Re-use .view-details-btn class for saving forms */
.view-details-btn {
    display: inline-block;
    padding: 8px 12px;
    background-color: var(--primary-blue);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.view-details-btn:hover {
    background-color: #004488;
}


.alert {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-weight: bold;
}

.alert.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}


/* Product Document Card */
.product-document-card {
    background-color: #e6f0ff;
    border: 1px solid #cce0ff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.product-document-card h3 {
    color: var(--primary-blue);
    font-size: 1em;
    margin-bottom: 5px;
}


/* -------------------- MEDIA QUERIES (Mobile/Tablet Responsiveness) -------------------- */

@media (max-width: 768px) {
    /* Header/Navigation adjustments */
    .header-content {
        flex-direction: column;
    }
    .top-nav {
        margin-top: 10px;
    }
    .container {
        flex-direction: column;
        margin: 10px;
    }
    .sidebar {
        flex: 1 1 auto;
    }
    .side-nav a {
        padding: 8px 10px;
        font-size: 0.9em;
    }
    
    /* Filter controls stack vertically for better mobile usability */
    .filter-controls {
        flex-direction: column;
        gap: 10px;
    }
    .filter-group {
        min-width: 100%; 
    }
    .filter-actions {
        /* Actions (Reset/Add) stack vertically on mobile */
        flex-direction: column;
        align-items: stretch;
    }
    .clear-filters-btn, .compact-add-btn {
        width: 100%;
        margin-top: 5px;
    }
    
    /* Product cards adjust better */
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    /* Table will scroll horizontally due to min-width: 700px */
}