/* Responsive CSS for Digital Voting System */

/* Global styles for all screen sizes */
html, body {
    overflow-x: hidden;
}

/* Global responsive adjustments */
@media (max-width: 767px) {
    /* Typography adjustments */
    h1 {
        font-size: 1.8rem !important;
    }
    h2 {
        font-size: 1.5rem !important;
    }
    h3 {
        font-size: 1.3rem !important;
    }
    
    /* Card adjustments */
    .card-header {
        padding: 0.75rem !important;
    }
    .card-body {
        padding: 1rem !important;
    }
    
    /* Table adjustments */
    .table-responsive {
        font-size: 0.9rem;
    }
    
    /* Button adjustments */
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Form adjustments */
    .form-control {
        font-size: 0.9rem;
    }
    
    /* Navbar adjustments */
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    /* Dashboard cards */
    .display-4 {
        font-size: 2.5rem !important;
    }
    
    /* Results page */
    .election-logo i {
        font-size: 3rem !important;
    }
    
    /* Alert adjustments */
    .alert {
        padding: 0.75rem !important;
    }
    
    /* Chart containers */
    .chart-container {
        height: 300px !important;
    }
}

/* Extra small devices */
@media (max-width: 575px) {
    /* Further reduce sizes */
    h1 {
        font-size: 1.5rem !important;
    }
    h2 {
        font-size: 1.3rem !important;
    }
    h3 {
        font-size: 1.1rem !important;
    }
    
    /* Dashboard cards */
    .display-4 {
        font-size: 2rem !important;
    }
    
    /* Buttons in rows */
    .btn-row .btn {
        margin-bottom: 0.5rem;
        width: 100%;
    }
    
    /* Table font size */
    .table-responsive {
        font-size: 0.8rem;
    }
    
    /* Chart containers */
    .chart-container {
        height: 250px !important;
    }
    
    /* Candidate cards in results */
    .candidate-card {
        margin-bottom: 1rem !important;
    }
}

/* Specific adjustments for results page */
@media (max-width: 767px) {
    .position-tab-content {
        padding: 0.5rem !important;
    }
    
    .position-tab-pane {
        padding: 0.5rem !important;
    }
    
    .nav-tabs .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .results-container .card {
        margin-bottom: 1rem;
    }
    
    .candidate-result-row {
        flex-direction: column;
    }
    
    .candidate-result-row .candidate-info {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .candidate-result-row .progress {
        width: 100%;
    }
}

/* Fix for tables on mobile */
@media (max-width: 767px) {
    .table-responsive-stack tr {
        display: flex;
        flex-direction: column;
        border-bottom: 3px solid #ddd;
        margin-bottom: 1rem;
    }
    
    .table-responsive-stack td {
        display: flex;
        padding: 0.5rem;
        align-items: center;
        border: none !important;
    }
    
    .table-responsive-stack td:before {
        content: attr(data-label);
        font-weight: bold;
        width: 40%;
        display: inline-block;
        color: #495057;
    }
    
    .table-responsive-stack thead {
        display: none;
    }
    
    .table-responsive-stack.table-mobile-active tbody tr {
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        border-radius: 4px;
        background-color: #fff;
    }
    
    /* Alternating row colors */
    .table-responsive-stack.table-mobile-active tbody tr:nth-child(odd) {
        background-color: rgba(0,0,0,0.02);
    }
    
    /* Improve spacing for action buttons */
    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: flex-end;
        width: 60%;
    }
}

/* Fix for admin dashboard on mobile */
@media (max-width: 767px) {
    .welcome-section {
        padding: 1rem !important;
    }
    
    .welcome-bg {
        display: none !important;
    }
    
    /* Dashboard cards */
    .card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 0.75rem !important;
    }
    
    .card-header .rounded-circle {
        margin-bottom: 0.5rem;
        margin-right: 0 !important;
    }
    
    /* Filter and search form */
    .filter-form .form-group {
        margin-bottom: 0.75rem;
    }
    
    .filter-form .btn {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    /* Action buttons in tables */
    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .action-buttons .btn {
        margin: 0.25rem;
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
}

/* Specific styles for manage voters page */
@media (max-width: 767px) {
    /* Search and filter section */
    .search-filter-container {
        flex-direction: column;
    }
    
    .search-filter-container .form-group {
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    /* Voter table */
    .voter-table th, .voter-table td {
        font-size: 0.85rem;
        padding: 0.5rem !important;
    }
    
    /* Status badges */
    .status-badge {
        display: block;
        width: 100%;
        margin-bottom: 0.25rem;
        text-align: center;
    }
}

/* Fix for voter ballot on mobile */
@media (max-width: 767px) {
    .ballot-container {
        padding: 0 !important;
    }
    
    .ballot-paper {
        border-radius: 0 !important;
        margin: 0 -15px !important;
        box-shadow: none !important;
    }
}

/* Voter interface responsive styles */
@media (max-width: 767px) {
    /* Voter navbar */
    .voter-navbar {
        padding: 0.5rem 1rem !important;
    }
    
    .voter-navbar .navbar-brand {
        font-size: 1.1rem;
    }
    
    .voter-navbar .navbar-nav .nav-link {
        padding: 0.5rem 0.75rem;
        text-align: center;
    }
    
    /* Voter dashboard */
    .voter-welcome {
        padding: 1.5rem 1rem !important;
    }
    
    .voter-welcome h1 {
        font-size: 1.5rem !important;
    }
    
    .voter-info-card {
        padding: 0.75rem !important;
    }
    
    /* Login page */
    .login-container {
        width: 100% !important;
        padding: 1.5rem !important;
    }
    
    .login-logo {
        width: 80px;
        height: 80px;
        margin-bottom: 1rem;
    }
    
    .login-form .form-group {
        margin-bottom: 1rem;
    }
    
    .login-form .btn {
        width: 100%;
    }
}

/* Specific styles for election results page */
@media (max-width: 767px) {
    /* Position tabs navigation */
    .position-tabs-container {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 5px;
    }
    
    .position-tabs-container .nav-item {
        white-space: nowrap;
    }
    
    /* Candidate results rows */
    .candidate-result-row {
        flex-direction: column;
    }
    
    .candidate-result-row .candidate-photo {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .candidate-result-row .candidate-details {
        width: 100%;
    }
    
    /* Winner cards */
    .winner-card {
        margin-bottom: 15px;
    }
    
    /* Charts */
    .chart-container {
        height: 250px;
    }
    
    /* Candidate photo container */
    .candidate-photo-container {
        width: 50px;
        height: 50px;
        margin: 0 auto;
        overflow: hidden;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #f8f9fa;
        position: relative;
    }
    
    .candidate-photo {
        width: 100%;
        height: 100%;
        object-fit: cover;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: auto;
    }
    
    .candidate-photo.default-photo {
        width: 90%;
        height: 90%;
        object-fit: contain;
    }
    
    /* Mobile progress bar */
    .mobile-progress {
        height: 15px;
        margin-top: 5px;
    }
    
    /* Candidate name container */
    .candidate-name-container {
        display: flex;
        flex-direction: column;
    }
    
    .candidate-name {
        font-weight: 500;
    }
    
    /* Status badges */
    .status-badge {
        display: inline-block;
        padding: 0.4em 0.6em;
        font-size: 0.75rem;
    }
    
    .candidate-result-row .candidate-info {
        width: 100%;
        margin-bottom: 1rem;
        text-align: center;
    }
    
    .candidate-result-row .candidate-img {
        width: 60px;
        height: 60px;
        margin: 0 auto 0.5rem;
    }
    
    .candidate-result-row .progress-container {
        width: 100%;
    }
    
    .candidate-result-row .vote-count {
        position: static;
        margin-top: 0.5rem;
        text-align: right;
    }
    
    /* Winner cards */
    .winner-card {
        margin-bottom: 1rem;
    }
    
    /* Charts */
    .chart-container {
        height: 250px !important;
    }
    
    /* Position tabs horizontal scrolling */
    .nav-tabs-scroll {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: -ms-autohiding-scrollbar;
        scrollbar-width: thin;
        padding-bottom: 5px;
    }
    
    .nav-tabs-scroll::-webkit-scrollbar {
        height: 5px;
    }
    
    .nav-tabs-scroll::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 10px;
    }
    
    .nav-tabs-scroll::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 10px;
    }
    
    .nav-tabs-scroll::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
    
    .nav-tabs-scroll .nav-link {
        white-space: nowrap;
        margin-right: 2px;
    }
}

/* Voter Management Mobile Styles */
@media (max-width: 767px) {
    /* Voter status display */
    .status-container {
        display: flex;
        flex-direction: column;
    }
    
    .status-badge {
        padding: 0.5em 0.75em;
        font-size: 0.8rem;
        display: inline-flex;
        align-items: center;
        white-space: nowrap;
    }
    
    .status-badge i {
        margin-right: 0.25rem;
    }
    
    /* Improve action buttons on mobile */
    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: flex-end;
    }
    
    .action-buttons .btn {
        padding: 0.25rem 0.5rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 2.5rem;
    }
    
    /* Voter table improvements */
    .voter-table td[data-label="Name"] {
        font-weight: 500;
    }
    
    .voter-table td[data-label="Index Number"] {
        font-family: monospace;
        letter-spacing: 0.5px;
    }
    
    /* Table responsive stack for mobile */
    .table-responsive-stack tr {
        display: flex;
        flex-direction: column;
        border-bottom: 1px solid #dee2e6;
        margin-bottom: 1rem;
    }
    
    .table-responsive-stack td,
    .table-responsive-stack th {
        text-align: left;
        display: block;
        border: none;
    }
    
    .table-responsive-stack th {
        display: none;
    }
    
    .table-responsive-stack td {
        position: relative;
        padding-left: 40%;
        min-height: 40px;
    }
    
    .table-responsive-stack td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 35%;
        font-weight: 700;
        text-align: left;
        padding-left: 0.75rem;
    }
    
    /* Election Results Mobile Styles */
    .position-results-container {
        padding: 0.75rem !important;
    }
    
    /* Enhanced candidate results display */
    .candidate-result-row {
        padding: 0.75rem !important;
        margin-bottom: 0.75rem !important;
        flex-wrap: wrap;
    }
    
    .candidate-photo {
        width: 50px;
        height: 50px;
        margin-right: 0.75rem;
    }
    
    .candidate-info {
        flex: 1 1 100%;
        margin-top: 0.5rem;
    }
    
    .candidate-name {
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }
    
    .vote-count-badge {
        font-size: 0.85rem;
        padding: 0.35rem 0.65rem;
        margin-top: 0.5rem;
        display: inline-flex;
        align-items: center;
    }
    
    .vote-percentage-badge {
        font-size: 0.85rem;
        padding: 0.35rem 0.65rem;
        margin-left: 0.5rem;
    }
    
    /* Position tab improvements */
    .position-tab {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
    
    .position-tab .badge {
        font-size: 0.7rem;
    }
    
    /* Progress bar improvements */
    .vote-progress {
        height: 12px !important;
        margin-top: 0.5rem;
        margin-bottom: 0.25rem;
    }
    
    .position-results-header h5 {
        font-size: 1rem;
    }
    
    .candidate-result {
        margin-bottom: 1.25rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px dashed rgba(0,0,0,0.1);
    }
    
    .candidate-result:last-child {
        border-bottom: none;
    }
    
    .candidate-name {
        font-size: 0.9rem;
        width: 100%;
    }
    
    .vote-count {
        margin-bottom: 0.5rem;
    }
    
    .vote-count .badge {
        font-size: 0.75rem;
    }
    
    .chart-container {
        height: 200px !important;
        margin-bottom: 1rem;
    }
    
    /* Position tabs scrolling */
    .nav-tabs-scroll {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: thin;
        -ms-overflow-style: none;
    }
    
    .nav-tabs-scroll::-webkit-scrollbar {
        height: 4px;
    }
    
    .nav-tabs-scroll::-webkit-scrollbar-thumb {
        background-color: rgba(0,0,0,0.2);
        border-radius: 4px;
    }
    
    .nav-tabs-scroll .nav-link {
        white-space: nowrap;
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
}
