/* Reset and Base Styles */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

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

.container,
.main-content,
.content-wrapper,
main {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 10px 96px;
    box-sizing: border-box;
}

/* Header Styles */
.main-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100%;
    margin: 0;
    padding: 0;
    line-height: 1;
}

.main-header nav.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 5px 0.6rem 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
    flex-wrap: nowrap;
    gap: 8px;
}

.nav-brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
}

.nav-brand .company-info {
    font-size: 0.72rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2px;
    flex-shrink: 1;
    flex-wrap: nowrap;
    align-items: center;
}

.nav-menu > li {
    position: relative;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    font-size: 0.82rem;
    white-space: nowrap;
    display: block;
}

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

/* Dropdown group for admin items */
.nav-dropdown > a::after {
    content: ' ▾';
    font-size: 0.7rem;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #5a4fa8;
    border-radius: 6px;
    min-width: 150px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 2000;
    padding: 4px 0;
}

.nav-dropdown-menu a {
    padding: 0.4rem 1rem;
    border-radius: 0;
    font-size: 0.82rem;
}

.nav-dropdown-menu a:hover {
    background: rgba(255,255,255,0.15);
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: block;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    font-size: 0.78rem;
    white-space: nowrap;
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 0.5rem 0 1rem;
}

.login-logo {
    height: 80px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(102,126,234,0.25));
}

.login-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.login-system-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: #333;
    letter-spacing: -0.3px;
}

.login-tagline {
    font-size: 0.75rem;
    color: #667eea;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.login-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #e0e0e0, transparent);
    margin: 0.5rem 0 1.25rem;
}

.login-heading {
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 1.5rem;
    letter-spacing: 0.2px;
}

.login-form h2 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: #333;
}

.login-form h3 {
    text-align: center;
    margin-bottom: 2rem;
    color: #666;
    font-weight: normal;
}

.login-info {
    margin-top: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 5px;
    font-size: 0.9rem;
}

.login-info p {
    margin: 0.25rem 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #667eea;
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

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

.btn-primary {
    background: #667eea;
}

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

.btn-info {
    background: #17a2b8;
}

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

.btn-secondary {
    background: #6c757d;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Forms */
.form {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Search Form */
.search-form {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.search-form .form-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-form select {
    min-width: 200px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.search-form input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.data-table tr:hover {
    background: #f8f9fa;
}

.text-right {
    text-align: right;
}

/* BY/TO Amount Columns */
.amount-by {
    text-align: right;
    color: #28a745;
    font-weight: 600;
}

.amount-to {
    text-align: right;
    color: #dc3545;
    font-weight: 600;
}

.amount-by:before {
    content: "Rs. ";
}

.amount-to:before {
    content: "Rs. ";
}

/* Status and Badges */
.status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
}

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

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

.status.completed {
    background: #d4edda;
    color: #155724;
}

.status.draft {
    background: #fff3cd;
    color: #856404;
}

.status.pending {
    background: #ffeaa7;
    color: #b8860b;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-warning {
    background: #ffc107;
    color: #333;
}

/* Dashboard */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    color: #333;
    font-size: 2rem;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s;
}

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

.stat-card.alert {
    border-left: 5px solid #dc3545;
}

.stat-card h3 {
    color: #666;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.stat-number {
    font-size: 3rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.stat-amount {
    font-size: 1.2rem;
    color: #28a745;
    margin-bottom: 1rem;
}

.stat-card a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.quick-actions {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Recent Transactions Section */
.recent-transactions {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-top: 2rem;
}

.recent-transactions .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.recent-transactions .section-header h2 {
    color: #333;
    font-size: 1.5rem;
}

.transaction-filter-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.transaction-filter-buttons .btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.transaction-filter-buttons .btn:hover {
    background: #e9ecef;
}

.transaction-filter-buttons .btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.transaction-action-buttons {
    display: flex;
    gap: 0.75rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.transaction-action-buttons .btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Transaction List Header */
.transaction-list-header {
    background: #667eea;
    color: white;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
}

.transaction-list-header .header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.transaction-list-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.add-button-inline .btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Transaction Cards */
.transaction-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.transaction-header {
    background: #e9ecef;
    color: #333;
    padding: 0.75rem 1.5rem;
    border-bottom: 2px solid #dee2e6;
}

.transaction-header h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    color: #667eea;
}

.transaction-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: #6c757d;
}

.transaction-meta span {
    display: flex;
    gap: 0.25rem;
}

.transaction-card .table-container {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

.transaction-card .data-table td.amount,
.recent-transactions .data-table td.amount {
    text-align: right;
    font-weight: 600;
    color: #667eea;
}

.transaction-card .data-table .total-row,
.recent-transactions .data-table .total-row {
    background: #f8f9fa;
    font-weight: bold;
    border-top: 2px solid #dee2e6;
}

.recent-transactions .data-table td.doc-number {
    font-weight: 600;
    color: #667eea;
    vertical-align: middle;
    border-right: 2px solid #dee2e6;
}

.recent-transactions .data-table td[rowspan] {
    vertical-align: middle;
    background: #f8f9fa;
}

.recent-transactions .data-table .action-cell {
    text-align: center;
    white-space: nowrap;
}

.recent-transactions .data-table .action-cell .btn {
    display: block;
    margin: 0.25rem auto;
    min-width: 60px;
}

.no-data, .no-selection {
    text-align: center;
    padding: 3rem 2rem;
    color: #6c757d;
}

.no-data p, .no-selection p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

/* Item Rows for Sales/GRN */
.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 5px;
}

.item-row select,
.item-row input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.item-row button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
}

.low-stock {
    background-color: #fff5f5;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

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

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

/* Footer */
.main-footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 3rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        flex-direction: column;
        gap: 0.5rem;
    }

    .container {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

    .item-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .search-form .form-row {
        flex-direction: column;
    }

    .page-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 0.875rem;
}
.btn-danger:hover {
    background: #c82333;
    color: white;
}