/* Universal CSS - Works on Android 4.2.2+ and all modern devices */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Device Layout Visibility */
/* Hide modern layout when on legacy device */
body.legacy-device .modern-device {
    display: none !important;
}

/* Hide legacy layout when on modern device */
body.modern-device .legacy-device {
    display: none !important;
}

body {
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    background-color: #f5f5f5;
    min-height: 100vh;
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

.main {
    min-height: calc(100vh - 130px);
    padding-top: 70px;
    /* Account for fixed header */
}

/* Header */
.header {
    background-color: #1976d2;
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 56px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border-bottom: 3px solid #0d47a1;
}

.header-content {
    display: table;
    width: 100%;
    height: 100%;
    padding: 0 15px;
}

.logo {
    display: table-cell;
    vertical-align: middle;
    font-size: 18px;
    font-weight: bold;
    width: 250px;
}

.logo-icon {
    margin-right: 8px;
}

.logo-text {
    color: #bbdefb;
}

.nav {
    display: table-cell;
    vertical-align: middle;
    text-align: right;
}

.nav-link {
    color: white;
    text-decoration: none;
    display: inline-block;
    padding: 10px 14px;
    margin-left: 5px;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 13px;
    font-weight: 500;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.nav-link.active {
    background-color: #0d47a1;
    border-color: #0d47a1;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.nav-link.logout {
    background-color: #c62828;
    border-color: #b71c1c;
}

.nav-link.logout:hover {
    background-color: #b71c1c;
    border-color: #a31515;
}

.nav-icon {
    margin-right: 4px;
}

/* Hide text on very small screens, keep icons */
@media (max-width: 480px) {
    .nav-text {
        display: none;
    }

    .logo-text {
        display: none;
    }

    .nav-link {
        padding: 8px;
        margin-left: 2px;
    }
}

/* Cards and Panels */
.card {
    background-color: #e3f2fd;
    border: 1px solid #1976d2;
    border-radius: 4px;
    margin-bottom: 15px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.card-header {
    background-color: #1976d2;
    border-bottom: 1px solid #64b5f6;
    padding: 12px 15px;
    font-weight: bold;
    color: #333;
}

.card-body {
    padding: 15px;
    background-color: #e3f2fd;
    color: #333;
}

.card-footer {
    background-color: #1976d2;
    border-top: 1px solid #64b5f6;
    padding: 10px 15px;
    text-align: right;
}

/* Grid System using Tables (Android 4.2.2 compatible) */
.row {
    display: table;
    width: 100%;
    margin-bottom: 15px;
}

.col {
    display: table-cell;
    padding: 0 10px;
    vertical-align: top;
}

.col-1 {
    width: 8.33%;
}

.col-2 {
    width: 16.66%;
}

.col-3 {
    width: 25%;
}

.col-4 {
    width: 33.33%;
}

.col-6 {
    width: 50%;
}

.col-8 {
    width: 66.66%;
}

.col-12 {
    width: 100%;
}

/* Mobile responsive - stack columns */
@media (max-width: 768px) {
    .row {
        display: block;
    }

    .col {
        display: block;
        width: 100% !important;
        padding: 5px 0;
    }
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    margin: 2px;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    background-color: #6c757d;
    color: white;
    border: 1px solid #6c757d;
    border-radius: 3px;
    cursor: pointer;
    vertical-align: middle;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

.btn:hover {
    background-color: #5a6268;
    border-color: #545b62;
    text-decoration: none;
    color: white;
}

.btn:active {
    background-color: #545b62;
    border-color: #4e555b;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Button Colors */
.btn-primary {
    background-color: #1976d2;
    border-color: #1976d2;
}

.btn-primary:hover {
    background-color: #e3f2fd;
    border-color: #bbdefb;
}

.btn-success {
    background-color: #28a745;
    border-color: #28a745;
}

.btn-success:hover {
    background-color: #1e7e34;
    border-color: #1c7430;
}

.btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

.btn-warning {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
    border-color: #d39e00;
    color: #212529;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

.form-control {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    background-color: #e3f2fd;
    border: 1px solid #1976d2;
    border-radius: 3px;
}

.form-control:focus {
    border-color: #1976d2;
    outline: 0;
    box-shadow: 0 0 3px rgba(26, 95, 95, 0.25);
}

/* Tables */
.table {
    width: 100%;
    margin-bottom: 15px;
    border-collapse: collapse;
    background-color: #e3f2fd;
    color: #333;
}

.table th,
.table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #1976d2;
    vertical-align: middle;
}

.table th {
    background-color: #1976d2;
    font-weight: bold;
    color: #333;
    border-top: 1px solid #1976d2;
}

.table-striped tbody tr:nth-child(odd) {
    background-color: #bbdefb;
}

.table-hover tbody tr:hover {
    background-color: #64b5f6;
}

/* Responsive table wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table-responsive {
        border: 1px solid #1976d2;
        border-radius: 3px;
    }
}

/* Status Indicators */
.status {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: 2px;
    color: white;
}

.status-running {
    background-color: #28a745;
}

.status-stopped {
    background-color: #6c757d;
}

.status-error {
    background-color: #dc3545;
}

.status-warning {
    background-color: #ffc107;
    color: #212529;
}

/* Messages */
.messages {
    margin-bottom: 15px;
}

.message {
    padding: 10px 15px;
    margin-bottom: 10px;
    border: 1px solid transparent;
    border-radius: 3px;
    position: relative;
}

.message-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.message-error {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.message-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.message-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

.message-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.message-close:hover {
    opacity: 1;
}

.message-icon {
    margin-right: 8px;
}

/* Footer */
.footer {
    background-color: #e3f2fd;
    color: #333;
    text-align: center;
    padding: 20px 10px;
    margin-top: 30px;
    font-size: 13px;
    border-top: 3px solid #bbdefb;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-text {
    margin-bottom: 5px;
    color: #b8e0e0;
}

.footer-icon {
    margin-right: 5px;
}

.footer-year {
    margin-left: 5px;
    color: #90caca;
}

.compatibility-notice {
    color: #90caca;
    font-weight: bold;
    margin-top: 5px;
}

.footer-logo {
    font-size: 18px;
    margin-right: 8px;
}

.footer-separator {
    margin: 0 10px;
    opacity: 0.5;
}

.footer-tagline {
    font-size: 11px;
    color: #90caca;
    margin-top: 5px;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.8;
}

.compat-icon {
    margin-right: 5px;
}

/* VM Action Buttons */
.vm-actions {
    white-space: nowrap;
}

.vm-actions .btn {
    margin: 1px;
    padding: 4px 8px;
    font-size: 11px;
}

/* Statistics Cards */
.stats-grid {
    display: table;
    width: 100%;
    margin-bottom: 20px;
}

.stat-card {
    display: table-cell;
    width: 25%;
    padding: 0 5px;
}

.stat-card .card {
    text-align: center;
    margin-bottom: 0;
}

.stat-number {
    font-size: 24px;
    font-weight: bold;
    color: #64b5f6;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #6c757d;
    font-weight: bold;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .stats-grid {
        display: block;
    }

    .stat-card {
        display: block;
        width: 100%;
        margin-bottom: 10px;
        padding: 0;
    }

    .vm-actions {
        white-space: normal;
    }

    .vm-actions .btn {
        display: block;
        width: 100%;
        margin: 2px 0;
    }
}

/* Loading States */
.loading {
    text-align: center;
    padding: 20px;
    color: #6c757d;
}

.loading:before {
    content: "⏳ ";
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-primary {
    color: #64b5f6;
}

.text-success {
    color: #28a745;
}

.text-danger {
    color: #dc3545;
}

.text-warning {
    color: #ffc107;
}

.text-info {
    color: #64b5f6;
}

.text-muted {
    color: #6c757d;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 5px;
}

.mb-2 {
    margin-bottom: 10px;
}

.mb-3 {
    margin-bottom: 15px;
}

.mt-0 {
    margin-top: 0;
}

.mt-1 {
    margin-top: 5px;
}

.mt-2 {
    margin-top: 10px;
}

.mt-3 {
    margin-top: 15px;
}

.p-0 {
    padding: 0;
}

.p-1 {
    padding: 5px;
}

.p-2 {
    padding: 10px;
}

.p-3 {
    padding: 15px;
}

.d-none {
    display: none;
}

.d-block {
    display: block;
}

.d-inline {
    display: inline;
}

.d-inline-block {
    display: inline-block;
}

/* Portrait Tablet Optimization (600px - 768px) */
@media (max-width: 768px) and (orientation: portrait) {

    /* Improve navigation for portrait tablets */
    .header {
        height: auto;
        min-height: 50px;
    }

    .header-content {
        display: block;
        padding: 8px 10px;
    }

    .logo {
        display: block;
        width: 100%;
        text-align: center;
        font-size: 16px;
        margin-bottom: 8px;
    }

    .nav {
        display: block;
        text-align: center;
        width: 100%;
    }

    .nav-link {
        font-size: 12px;
        padding: 6px 10px;
        margin: 2px;
    }

    /* Adjust main content for portrait */
    .container {
        padding-top: 100px !important;
        /* More space for taller header */
    }

    /* Make tables more readable */
    .table-responsive {
        font-size: 12px;
    }

    .table th,
    .table td {
        padding: 6px 4px;
    }

    /* Stack cards better */
    .card {
        margin-bottom: 10px;
    }

    .card-header {
        font-size: 14px;
        padding: 8px 10px;
    }

    .card-body {
        padding: 10px;
    }

    /* Improve buttons in portrait */
    .btn {
        padding: 10px 14px;
        font-size: 13px;
        margin: 3px;
        min-width: 80px;
    }

    /* Better gauge sizing for portrait */
    .gauge {
        max-width: 280px;
        margin: 10px auto;
    }

    /* Improve form inputs */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 14px;
        padding: 10px;
    }

    /* Better spacing for form groups */
    .form-group {
        margin-bottom: 12px;
    }

    label {
        font-size: 13px;
        margin-bottom: 4px;
    }
}