@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --info-color: #36b9cc;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --light-color: #f8f9fc;
    --dark-color: #5a5c69;
    --bg-gradient: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    /* Soft gradient */
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --border-radius: 0.5rem;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(5px);
    margin-top: auto;
    /* Push to bottom */
}

.footer a {
    color: var(--primary-color);
    transition: color 0.2s;
}

.footer a:hover {
    color: var(--dark-color);
    text-decoration: underline !important;
}

/* Navbar */
.navbar {
    background: rgba(33, 37, 41, 0.95) !important;
    /* Dark background */
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-brand img {
    height: 60px !important;
    width: auto !important;
    margin: 0 !important;
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, .55);
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: rgba(255, 255, 255, .75);
}

/* Search Input */
#searchInput {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding-left: 1rem;
    padding-right: 1rem;
}

#searchInput::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#searchInput:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: none;
    color: white;
}


/* Main Layout */
.main-container {
    padding: 2rem 0;
}

.main-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 2rem;
    margin-top: 2rem;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    color: var(--dark-color);
}

label {
    display: inline-block;
    width: 100%;
    /* Full width in modal context generally better */
    font-weight: 500;
    margin-bottom: 0.5rem;
    padding-top: 5px;
    padding-left: 0;
}

/* Image styles */
img {
    border-radius: 4px;
}

#myimg {
    width: 150px;
    height: 200px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border: 1px dashed #ccc;
    padding: 10px;
    border-radius: var(--border-radius);
    background: #f8f9fa;
    display: block;
    margin: 0 auto;
}

.table-img {
    width: 75px;
    height: 100px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #eee;
    background: #f8f9fa;
}

/* Modal */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.modal-header {
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.modal-footer {
    border-top: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.modal-footer .btn>button {
    margin: 5px;
}

/* Table */
.table-responsive {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table thead th {
    background-color: #f8f9fc;
    border-bottom: 2px solid #e3e6f0;
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    vertical-align: middle;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

td {
    vertical-align: middle;
}

/* Table Images - 3:4 Ratio */
.table-img {
    width: 60px;
    height: 80px;
    /* 3:4 ratio */
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}


/* Buttons */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.floating-add-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

@media (max-width: 991px) {
    .navbar .container {
        flex-wrap: wrap;
        gap: 10px;
    }

    .navbar-brand {
        flex-grow: 1;
    }

    /* Move add button to the right of brand */
    .navbar .btn-primary {
        margin-left: auto !important;
    }

    /* Make search bar full width on row 2 */
    .navbar form,
    .navbar .d-flex.mx-auto {
        width: 100% !important;
        max-width: 100% !important;
        order: 3;
        /* Force to bottom */
        margin: 0 !important;
    }
}

/* Mobile Table Transformations */
@media (max-width: 768px) {

    /* Hide table header */
    .table thead {
        display: none;
    }

    /* Make table display block */
    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    /* Transform rows into cards */
    .table tbody tr {
        background: #fff;
        margin-bottom: 2rem;
        border-radius: var(--border-radius);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        padding: 1rem;
        position: relative;
    }

    /* Transform cells into rows within card */
    .table tbody td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid #eee;
        height: auto;
        min-height: 40px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        /* HIDE ALL BY DEFAULT on mobile */
        display: none;
    }

    /* ALWAYS SHOW these columns */
    .table tbody td[data-label="Name"],
    .table tbody td[data-label="Price"],
    .table tbody td[data-label="Image"] {
        display: flex;
        padding-left: 0;
        /* Remove padding for these clean looks */
        justify-content: space-between;
        text-align: left;
    }

    /* Image Specific */
    .table tbody td[data-label="Image"] {
        justify-content: center;
        border-bottom: 0;
        margin-bottom: 10px;
        order: -1;
        /* Move image to top */
    }

    .table tbody td[data-label="Image"]::before {
        display: none;
    }

    /* Name Specific */
    .table tbody td[data-label="Name"] {
        font-size: 1.1rem;
        color: var(--dark-color);
        border-bottom: 0;
        padding-right: 40px;
        /* Space for toggle button */
    }

    .table tbody td[data-label="Name"]::before {
        display: none;
    }

    /* Price Specific */
    .table tbody td[data-label="Price"] {
        color: var(--success-color);
        font-weight: 700;
        font-size: 1.2rem;
        justify-content: center;
        border-bottom: 1px solid #eee;
        padding-bottom: 10px;
    }

    .table tbody td[data-label="Price"]::before {
        display: none;
    }

    /* EXPANDED STATE logic */
    .table tbody tr.expanded td {
        display: flex;
        /* Show all when expanded */
    }

    /* When expanded, add padding back to normal fields */
    .table tbody tr.expanded td:not([data-label="Name"]):not([data-label="Price"]):not([data-label="Image"]) {
        padding-left: 50%;
        background: #f8f9fa;
        /* Slight background for details */
    }

    .table tbody td:last-child {
        border-bottom: 0;
        justify-content: center;
        margin-top: 10px;
        background: transparent !important;
    }

    /* Add labels using before pseudo-element */
    .table tbody td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: var(--secondary-color);
    }

    /* Hide labels for top prominent items */
    .table tbody td[data-label="Name"]::before,
    .table tbody td[data-label="Price"]::before,
    .table tbody td[data-label="Image"]::before {
        display: none;
    }

    .table-img {
        width: 100% !important;
        max-width: 150px;
        height: auto !important;
        aspect-ratio: 3 / 4;
        object-fit: cover;
        border-radius: var(--border-radius);
    }

    /* Action buttons container */
    .table tbody td[data-label="Actions"] {
        flex-direction: row;
        gap: 10px;
        padding-left: 0 !important;
    }

    .table tbody td[data-label="Actions"]::before {
        display: none;
    }

    .update-row,
    .delete-row {
        width: 100%;
        margin: 0 !important;
        /* Ensure normal button height */
        padding: 0.5rem 1rem;
        height: auto;
    }

    /* Chevron button visibility */
    .mobile-toggle-btn {
        z-index: 10;
        background-color: rgba(0, 0, 0, 0.05);
        color: var(--dark-color);
        border: 1px solid rgba(0, 0, 0, 0.1);
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: all 0.2s ease;
    }

    .mobile-toggle-btn:hover,
    .mobile-toggle-btn:focus {
        background-color: rgba(0, 0, 0, 0.1);
        transform: scale(1.05);
    }
}

@media (max-width: 576px) {
    .modal-content {
        padding: 10px;
    }

    .modal-footer .btn>button,
    .modal-footer .btn {
        width: 100%;
        margin-bottom: 8px;
    }

    .imagebox img {
        width: 100%;
        max-width: 200px;
        height: auto;
    }

    .table-responsive {
        margin-bottom: 1rem;
    }
}