/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

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

/* Header Styles */
header {
    background: linear-gradient(135deg, #4b9d7c, #2e7a5f);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 2rem;
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 15px;
}

.nav-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 1.3rem;
    padding: 8px 14px;
    border-radius: 5px;
    cursor: pointer;
    flex-shrink: 0;
}

.nav-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 5px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

nav a:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

nav a.active {
    background-color: rgba(255, 255, 255, 0.3);
    font-weight: bold;
}

/* Nav dropdowns */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    background: none;
    border: none;
    font: inherit;
    color: white;
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 5px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.nav-dropdown-toggle:hover,
.nav-dropdown.active .nav-dropdown-toggle {
    background-color: rgba(255, 255, 255, 0.2);
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    flex-direction: column;
    min-width: 180px;
    background: #2e7a5f;
    border-radius: 5px;
    padding: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    z-index: 10;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: flex;
}

/* Hover/focus-only opening is a desktop convenience. On touch devices a tap
   both toggles .open via JS AND leaves the button :focus-within, so scoping
   this to wider screens keeps a second tap able to actually close it. */
@media (min-width: 769px) {
    .nav-dropdown:hover .nav-dropdown-menu,
    .nav-dropdown:focus-within .nav-dropdown-menu {
        display: flex;
    }
}

.nav-dropdown-menu a {
    white-space: nowrap;
}

/* Login Page */
.login-body {
    background: linear-gradient(135deg, #4b9d7c, #2e7a5f);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    background-color: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 500px;
}

.login-container h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #2e7a5f;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #4b9d7c;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #4b9d7c;
    box-shadow: 0 0 0 3px rgba(75, 157, 124, 0.2);
}

.btn {
    width: 100%;
    padding: 15px;
    background-color: #4b9d7c;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    font-weight: bold;
}

.btn:hover {
    background-color: #2e7a5f;
    transform: translateY(-2px);
}

.btn-small {
    padding: 8px 12px;
    font-size: 14px;
}

.btn-danger {
    background-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
}

.btn-success {
    background-color: #28a745;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-primary {
    background-color: #4b9d7c;
}

.btn-primary:hover {
    background-color: #2e7a5f;
}

.register-link {
    text-align: center;
    margin-top: 20px;
}

.register-link a {
    color: #4b9d7c;
    text-decoration: none;
}

.register-link a:hover {
    text-decoration: underline;
}

/* Main Content */
main {
    background-color: white;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.page-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.page-header h2 {
    color: #2e7a5f;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Stats Cards */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card i {
    color: #4b9d7c;
    margin-bottom: 10px;
}

.stat-card h3 {
    font-size: 2rem;
    margin-bottom: 5px;
    color: #2e7a5f;
}

/* Alerts Section */
.alerts-section {
    margin-bottom: 30px;
}

.alerts-section h3 {
    color: #2e7a5f;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-card {
    background-color: #fff8e1;
    border-left: 4px solid #ffc107;
    padding: 20px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.alert-card h4 {
    color: #ff9800;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-card ul {
    padding-left: 20px;
}

.alert-card li {
    margin-bottom: 5px;
}

/* Forms */
.form-section {
    background-color: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.form-section h3 {
    color: #2e7a5f;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #4b9d7c;
}

/* Autocomplete suggestions */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    max-height: 220px;
    overflow-y: auto;
}

.autocomplete-suggestion {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-suggestion:last-child {
    border-bottom: none;
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion.active {
    background-color: #e8f5ef;
}

.autocomplete-suggestion .suggestion-stock {
    color: #777;
    font-size: 12px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

th {
    background-color: #4b9d7c;
    color: white;
    font-weight: bold;
}

tr:hover {
    background-color: #f8f9fa;
}

.actions {
    display: flex;
    gap: 5px;
    justify-content: center;
}

/* Status Badges */
.status-badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

.status-normal {
    background-color: #d4edda;
    color: #155724;
}

.status-low {
    background-color: #f8d7da;
    color: #721c24;
}

.status-active {
    background-color: #d4edda;
    color: #155724;
}

.status-inactive {
    background-color: #f8d7da;
    color: #721c24;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    position: relative;
    animation: modalopen 0.4s;
}

@keyframes modalopen {
    from {opacity: 0; transform: translateY(-50px);}
    to {opacity: 1; transform: translateY(0);}
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 15px;
    right: 20px;
}

.close:hover {
    color: black;
}

/* Alerts */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    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;
}

/* Profile Section */
.profile-section {
    margin-bottom: 30px;
    padding: 25px;
    background-color: #f8f9fa;
    border-radius: 10px;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: normal;
}

/* Reports Section */
.report-section {
    margin-bottom: 30px;
    padding: 25px;
    background-color: #f8f9fa;
    border-radius: 10px;
}

.report-section h3 {
    color: #2e7a5f;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Tenants List */
.tenants-list {
    margin-bottom: 30px;
}

.tenants-list h3 {
    color: #2e7a5f;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.current-admins {
    margin-bottom: 30px;
}

.current-admins h3 {
    color: #2e7a5f;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    nav {
        display: none;
        flex-direction: column;
        margin-top: 15px;
    }

    nav.nav-open {
        display: flex;
    }

    nav a {
        width: 100%;
        justify-content: flex-start;
    }

    .nav-dropdown-toggle {
        width: 100%;
        justify-content: flex-start;
    }

    .nav-dropdown-menu {
        /* Shown only when its .nav-dropdown has .open (see the shared rule
           above) or on desktop hover/focus -- never unconditionally. */
        position: static;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.1);
        width: 100%;
    }

    .nav-dropdown-menu a {
        width: 100%;
        justify-content: flex-start;
        padding-left: 30px;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Responsive tables: stack each row as a labeled card instead of
       forcing the page to scroll horizontally to read a wide table. Each
       <td> needs a data-label="Column Name" attribute (the value the ::before
       below displays); a <td class="actions"> is laid out as its own
       full-width row of buttons instead of a label/value pair. */
    table {
        font-size: 14px;
    }

    thead {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    table, tbody, tr, td {
        display: block;
        width: 100%;
    }

    table {
        border: none;
        box-shadow: none;
        background: transparent;
    }

    tr {
        margin-bottom: 15px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }

    td {
        padding: 10px 12px 10px 45%;
        text-align: right;
        position: relative;
        border-bottom: 1px solid #eee;
        min-height: 20px;
    }

    td:last-child {
        border-bottom: none;
    }

    td::before {
        content: attr(data-label);
        position: absolute;
        left: 12px;
        width: 40%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        color: #4b9d7c;
    }

    td.actions {
        text-align: left;
        padding: 10px 12px;
        flex-wrap: wrap;
    }

    td.actions::before {
        content: none;
    }
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    color: #6c757d;
    font-size: 14px;
}

/* Low stock items */
.low-stock {
    background-color: #fff8e1 !important;
}

/* Dashboard Header */
.dashboard-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #2e7a5f;
}

.dashboard-header p {
    color: #6c757d;
    margin-top: 5px;
}
